PyPlot label_position Y-axis in Julia

pyplot

#1

I basically want the Y label (using PyPlot) on the right side with it’s ticks. For Python I found the comand ax.yaxis.set_label_position("right") .

But if I do

ax=gca()
ax.yaxis.set_label_position("right")

or ax[:yaxis](label_position="right")

Julia says “type PyObject has no field yaxis” for the first case and “TypeError(”‘YAxis’ object is not callable",)" for the second case. How do I adress it correctly?


#2

I haven’t used PyPlot other than through Plots.jl in a long time, but this seems to work:

using PyPlot
ax = gca()
ax[:yaxis][:set_label_position]("right")
ax[:yaxis][:label_position] # Returns "right"

For reference, if you wanted to do it in Plots.jl instead you could do:

using Plots
pyplot() # If you insist on the PyPlot backend

plot(rand(100), ymirror = true)