proplot icon indicating copy to clipboard operation
proplot copied to clipboard

bug: wrong xticklabels with log scale dualx

Open kinyatoride opened this issue 1 year ago • 2 comments

Description

dualx seems to have an issue handling log scale axis.

Steps to reproduce

import numpy as np
import proplot as pplt

x = np.logspace(-1, 1, 100)

fig, ax = pplt.subplots()
ax.semilogx(x, np.sin(x))
ax.dualx(lambda x: 1/x)

The top tick labels are a mess. output

Equivalent steps in matplotlib

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0.1, 10, 1000)
fig, ax = plt.subplots()
ax.semilogx(x, np.sin(x))
ax.grid()
ax.secondary_xaxis('top', functions=(lambda x: 1/x, lambda x: 1/x))

output1

Proplot version

3.4.3 0.9.7

kinyatoride avatar Jul 31 '24 20:07 kinyatoride

Not a real solution but for now you could do:

import numpy as np
import proplot as plt

x = np.logspace(-1, 1, 100)
fig, ax = plt.subplots()
ax.semilogx(x, np.sin(x))
tax = ax.dualx(lambda x: x)
tax.invert_xaxis()
plt.show(block=1)

cvanelteren avatar Aug 16 '24 09:08 cvanelteren

Which produces image

cvanelteren avatar Aug 16 '24 09:08 cvanelteren