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
I am plotting a graph in logscale and I want to set manually the y_ticks. However, in the graph I was using, ax.set_yticks was not doing anything. I found out that when ax.set_ylim is set to a large enough interval, I can have my custom yticks, but when the interval is small, ticks get "locked" and there is no way to change them to my liking.
I did check that the issue only happens when plotting in logscale, hence I do believe that the problem is related to this or a similar issue: #8768
I do provide a minimal working example below.
Code for reproduction
importnumpyasnpimportmatplotlib.pyplotaspltplt.figure()
#Generate some dummy power-law data that looks linear in log-logx=np.linspace(1e3, 1e5, 60)
y=np.power(x, -2) *np.random.uniform(size=60)
plt.plot(x,y)
#Set logscale. Things work as expected in linear scale.ax=plt.gca()
ax.set_xscale("log")
ax.set_yscale("log")
#IF THIS IS SET TO A LARGER INTERVAL, I.E. FROM 1E-10 TO 1E-7, #THEN THE ONLY YTICK PRESENT IS THE ONE I SET. FOR SMALLER VALUES,#SUCH AS THE ONE HERE, I DO HAVE MORE TICKS APART FROM THE SELECTED ONEax.set_ylim(5e-8, 1e-7)
ax.set_yticks([6.56e-8])
ax.set_yticklabels(["mytick"])
plt.show()
Actual outcome
When the interval in y_lim is small enough, I do have more ticks than the one I want to have. But when the interval is larger, only the one I selected is present.
Expected outcome
I would like to have only the ytick that I selected in ax.set_yticks displayed, no matter how large the interval is.
Additional information
No response
Operating system
No response
Matplotlib Version
3.3.4
Matplotlib Backend
No response
Python version
3.8.8
Jupyter version
No response
Installation
No response
The text was updated successfully, but these errors were encountered:
The additional ticks are minor ticks. You can turn them off by either ax.minorticks_off() to get rid of the ticks and the labels or by ax.set_yticklabels([], minor=True) to keep the ticks, but not the labels.
Bug summary
I am plotting a graph in logscale and I want to set manually the
y_ticks
. However, in the graph I was using,ax.set_yticks
was not doing anything. I found out that whenax.set_ylim
is set to a large enough interval, I can have my custom yticks, but when the interval is small, ticks get "locked" and there is no way to change them to my liking.I did check that the issue only happens when plotting in logscale, hence I do believe that the problem is related to this or a similar issue: #8768
I do provide a minimal working example below.
Code for reproduction
Actual outcome
When the interval in
y_lim
is small enough, I do have more ticks than the one I want to have. But when the interval is larger, only the one I selected is present.Expected outcome
I would like to have only the ytick that I selected in
ax.set_yticks
displayed, no matter how large the interval is.Additional information
No response
Operating system
No response
Matplotlib Version
3.3.4
Matplotlib Backend
No response
Python version
3.8.8
Jupyter version
No response
Installation
No response
The text was updated successfully, but these errors were encountered: