2
votes

I apologise if this has already been asked, I've searched long and hard on this site and couldn't find anything that worked. I'm using Julia, specifically the Juno IDE, and I am trying to use PyPlot to create my graphs. I wanted to set the y axis height when plotting, but leave the x axis variable. Here is the code I have been using to generate my plots

fig = figure()
ax = fig[:add_axes]
BEFE250 = (plot(s1, s2, lw=1.0, "-", color="b"))

ylabel("u(x,t)", size=20)
xlabel("t", size=20)

gcf()

which gives me

Reflection

However, I need space in the top left corner as I am going to layer another picture on top in latex. So I need to set the y-axis height to between -3 and 3. However, if I set the axes height in PyPlot

fig = figure()
ax = fig[:add_axes]([0.1, 0.1, -3.0, 3.0])
BEFE250 = (plot(s1, s2, lw=1.0, "-", color="b"))

ylabel("u(x,t)", size=20)
xlabel("t", size=20)

gcf()

then it switches the orientation of the x-axis. If I set the axis height after running the plot, PyPlot puts the picture in a box in a legend off to the side of the main picture, and the main picture is empty? If someone could help me out it would be greatly appreciated.

Thanks for your help.

EDIT: Using xlim=(-10.,10.) and ylim=(-2.,12.) doesn't work either. PyPlot still adapts the axes to the data.

1

1 Answers

2
votes

Try xlim(-10, 10) and ylim(-2, 12) after the plot command:

plot(s1, s2, lw=1.0, "-", color="b")
ylim(-3, 3)

Just try this, without the add_axes.

You probably also want LaTeX labels -- just add an L before the string, which gives a special LaTeX string from the LaTeXString package. You can either just add the L, or add $ inside too:

ylabel(L"u(x,t)", size=20)
ylabel(L"$u(x,t)$", size=20)

[The $ are necessary in certain circumstances that I forget.]

I'm not sure how good the PyPlot support is in Juno. You might want to try this in IJulia.

By the way, is there a reason you want to layer on a separate figure in LaTeX? That might not be the best way to do it.