Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Labels
Description
Bug report
Y tick locations on secondary y-axis are ignored
I create a secondary y-axis on a plot and set custom y tick locations. But my specified tick locations get ignored. In this example the right hand y-axis should have ticks at positions [1, 2, 5, 10].
Code for reproduction
importnumpyasnpimportmatplotlib.pyplotaspltfig,ax=plt.subplots()x=np.arange(1,100)y=np.sqrt(x)ax.plot(x,y)ax.set_xlim(0,100)ax.set_ylim(1,10)secax=ax.secondary_yaxis('right',functions=(lambdaz:10*np.log10(z),lambdaz:np.power(10.0,z/10.0)))# Secondary y-axis tick locations get ignored.secax.set_yticks([1,2,5,10])plt.show()plt.close()
Actual outcome
Expected outcome
I expect the right hand y-axis to be labeled with ticks at positions [1, 2, 5, 10], not [0, 2, 4, 6, 8, 10]. If I try to force this by usingmatplotlib.tickerFixedLocator
, I still see the same problem.
Matplotlib version
- Operating system: Windows 10 Build 10.0.18363
- Matplotlib version: 3.1.3
- Matplotlib backend (
print(matplotlib.get_backend())
): Qt5Agg - Python version: Python 3.7.4 (default, Aug 9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
- Jupyter version (if applicable): N/A
- Other libraries:
# packages in environment at C:\Miniconda3:## Name Version Build Channelasn1crypto 1.3.0 py37_0astroid 2.3.3 py37_0blas 1.0 mklca-certificates 2020.1.1 0certifi 2019.11.28 py37_0cffi 1.13.2 py37h7a1dbc1_0chardet 3.0.4 py37_1003colorama 0.4.3 py_0conda 4.8.2 py37_0conda-package-handling 1.6.0 py37h62dcd97_0console_shortcut 0.1.1 3cryptography 2.8 py37h7a1dbc1_0cycler 0.10.0 py37_0freetype 2.9.1 ha9979f8_1icc_rt 2019.0.0 h0cc432a_1icu 58.2 ha66f8fd_1idna 2.8 py37_0intel-openmp 2019.4 245isort 4.3.21 py37_0jpeg 9b hb83a4c4_2kiwisolver 1.1.0 py37ha925a31_0lazy-object-proxy 1.4.3 py37he774522_0libpng 1.6.37 h2a8f88b_0matplotlib 3.1.3 py37_0matplotlib-base 3.1.3 py37h64f37c6_0mccabe 0.6.1 py37_1menuinst 1.4.16 py37he774522_0mkl 2019.4 245mkl-service 2.3.0 py37hb782905_0mkl_fft 1.0.15 py37h14836fe_0mkl_random 1.1.0 py37h675688f_0numpy 1.18.1 py37h93ca92e_0numpy-base 1.18.1 py37hc3f5095_1openssl 1.1.1d he774522_3pandas 0.25.3 py37ha925a31_0patsy 0.5.1 py37_0pip 20.0.2 py37_1powershell_shortcut 0.0.1 2pycosat 0.6.3 py37he774522_0pycparser 2.19 py37_0pylint 2.4.4 py37_0pyopenssl 19.1.0 py37_0pyparsing 2.4.6 py_0pyqt 5.9.2 py37h6538335_2pysocks 1.7.1 py37_0python 3.7.4 h5263a28_0python-dateutil 2.8.1 py_0pytz 2019.3 py_0pywin32 227 py37he774522_1qt 5.9.7 vc14h73c81de_0requests 2.22.0 py37_1ruamel_yaml 0.15.87 py37he774522_0scipy 1.3.2 py37h29ff71c_0seaborn 0.9.0 pyh91ea838_1setuptools 45.1.0 py37_0sip 4.19.8 py37h6538335_0six 1.14.0 py37_0sqlite 3.31.1 he774522_0statsmodels 0.11.0 py37he774522_0tornado 6.0.3 py37he774522_0tqdm 4.42.0 py_0urllib3 1.25.8 py37_0vc 14.1 h0510ff6_4vs2015_runtime 14.16.27012 hf0eaf9b_1wheel 0.34.2 py37_0win_inet_pton 1.1.0 py37_0wincertstore 0.2 py37_0wrapt 1.11.2 py37he774522_0xlrd 1.2.0 py37_0yaml 0.1.7 hc54c509_2zlib 1.2.11 h62dcd97_3
Installed via Miniconda distro, standard channels for packages.