Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

twiny() ? #2579

Closed
jenfenghsu opened this issue Apr 14, 2020 · 1 comment · Fixed by #4488
Closed

twiny() ? #2579

jenfenghsu opened this issue Apr 14, 2020 · 1 comment · Fixed by #4488
Labels
extension new behaviour

Comments

@jenfenghsu
Copy link

jenfenghsu commented Apr 14, 2020

Is it possible to have similar hack as twinx() to have secondary x-axis on top of the plot? This can be useful when displaying the same curve with alternative units. See below for example. Or, any suggestion to achieve the same in Julia Plots? Thanks!
image

My minimal example code with PyPlot package (but I'd very much love to continue using Plots):

fig, ax1 = PyPlot.subplots(num="Temperature Dependence",figsize=(10,6),facecolor="0.98")

ax1.set_xlabel("Temperature (°C)", fontsize=20)
ax1.set_ylabel("Response", fontsize =20)
x = collect(0:0.1:100)
y = 0.1 .* x .^ 2 - 5 .* x .+ 8
ax1.plot(x, y, lw=1., label="Object 1") 
ax1.legend(loc="best")
ax1.grid(true)

ax2 = ax1.twiny()
ax2.set_xlabel("Temperature (°F)", fontsize =20)
ax2.plot(x .* 9/5 .+ 32, y, lw=0.) # Ghost plot to show scale

PyPlot.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension new behaviour
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants