You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
matplotlibrc: new entry for placing y-axis tick label on Right or Left hand side. #10267
I understand that currently there is a way to place y-axis tick labels on the right hand side instead of the left by default, by calling ax.yaxis.tick_right().
See this SO post This is obviously very useful for people who study time series and latest values are sometimes more important than older values.
I'd like to suggest making that a profile setting in matplotlibrc. Open to dicussion here.
Would someone be able to point out where in the code base I can start looking for this? Happy to take a stab at this.
I found properties for ticks. But not for tick labels and axis label.
Thx
On 20 Jan 2018, at 21:58, Jody Klymak ***@***.***> wrote:
I think a PR along these lines would be welcome. Might as well do xlabel as well..
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
Make use of these properties in matplotlib.axes._base._AxesBase.__init__():
self.tick_params(
top=rcParams['xtick.top'] and rcParams['xtick.minor.top'],
bottom=rcParams['xtick.bottom'] and rcParams['xtick.minor.bottom'],
left=rcParams['ytick.left'] and rcParams['ytick.minor.left'],
right=rcParams['ytick.right'] and rcParams['ytick.minor.right'],
labelleft=rcParams['ytick.labelleft'] and rcParams['ytick.minor.left'], # new here
labelright=rcParams['ytick.labelright'] and rcParams['ytick.minor.right'], # new here
which='minor')
self.tick_params(
top=rcParams['xtick.top'] and rcParams['xtick.major.top'],
bottom=rcParams['xtick.bottom'] and rcParams['xtick.major.bottom'],
left=rcParams['ytick.left'] and rcParams['ytick.major.left'],
right=rcParams['ytick.right'] and rcParams['ytick.major.right'],
labelleft=rcParams['ytick.labelleft'] and rcParams['ytick.major.left'], # new here
labelright=rcParams['ytick.labelright'] and rcParams['ytick.major.right'], # new here
which='major')
This worked on my Linux machine running matplotlib 2.1.1. What do you think? If this does the job then I will also add the same for xtick.labeltop and xtick.labelbottom.
The following code would produce the plots that show these changes worked. I also checked pandas basic plots, also worked for secondary_y parameter, although it'd swap the two y-axes around it doesn't seem to be a huge deal breaker.
Any suggestion on any test cases? Not sure how that is usually done here.
I have these changes ready for a PR, which branch should I submit this to?
%matplotlib inline
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
import pandas as pd
print(mpl.rcParams['ytick.right'], mpl.rcParams['ytick.labelright'])
print(mpl.rcParams['ytick.left'], mpl.rcParams['ytick.labelleft'])
x = np.array([x for x in range(10)])
plt.plot(x)
y = np.array([y+10+np.random.normal(0, 3) for y in range(10)])
df = pd.DataFrame([x,y]).T
df.plot()
df.plot(secondary_y=1)
The issue was almost already fixed when you asked, but if you are still interested in participating into this kind of issues, you might want to have a look at similar issues tagged as good first issue, new-contributor-friendly and/or rcparams. For example, randomly picking one of them, one may try to revive #8479 (addressing #8109), which seems to have stalled.
Activity
jklymak commentedon Jan 20, 2018
I think a PR along these lines would be welcome. Might as well do xlabel as well..
esvhd commentedon Jan 21, 2018
esvhd commentedon Jan 21, 2018
@jklymak, I did some work on this, a quick solution to y-axis tick labels:
matplotlibrc:matplotlib.rcsetup.pyso that these properties are recognized:matplotlib.axes._base._AxesBase.__init__():This worked on my Linux machine running
matplotlib 2.1.1. What do you think? If this does the job then I will also add the same forxtick.labeltopandxtick.labelbottom.The following code would produce the plots that show these changes worked. I also checked
pandasbasic plots, also worked forsecondary_yparameter, although it'd swap the two y-axes around it doesn't seem to be a huge deal breaker.Any suggestion on any test cases? Not sure how that is usually done here.
I have these changes ready for a PR, which branch should I submit this to?
tgmiller5 commentedon Feb 1, 2018
I am interested in participating in this. Is there a way to include me as a participant?
QuLogic commentedon Feb 7, 2018
Fixed by #10306.
afvincent commentedon Feb 7, 2018
@tgmiller5 Apologies for the answer delay!
The issue was almost already fixed when you asked, but if you are still interested in participating into this kind of issues, you might want to have a look at similar issues tagged as good first issue, new-contributor-friendly and/or rcparams. For example, randomly picking one of them, one may try to revive #8479 (addressing #8109), which seems to have stalled.