Fixing problems with my plot

Hello!

I have a plot which currently looks like:

There are something I would like to change about it, which I cannot figure out how to do:

• Make x and y axis “intersect”, so it does not say “0” twice
• Make it a “square plot”, such that the help grid becomes square too and not rectangular
• I want a black box around the plot

Something which looks a bit like what I want is (ignore the dashed horizontal lines):

The code I am using to generate the first image currently is:

using Plots
using PGFPlotsX
using PlotThemes

pgfplotsx()

theme(:default,
fglegend = colorant"#000000", #legend
guidefontcolor = colorant"#000000",
showaxis = true,
formatter = :scientific,
aspect_ratio = :equal, #:equal
widen=true,
ylims=(0,100),
thickness_scaling = 1.25,
)
plot(rand(100)*100)
plot!(rand(100)*100)
xlabel!("Moving Average Sample (it is not time anymore due to averaging)")
ylabel!(raw"E $\left[\frac{\text{J}}{\text{kg}}\right]$")


Would anyone happen to know how to achieve this? For example to get the “square shape” I tried using aspect_ratio = :equal but apparently I misunderstood what it actually does etc.

Kind regards


julia> theme(:default,
fglegend = colorant"#000000", #legend
guidefontcolor = colorant"#000000",
showaxis = true,
formatter = :scientific,
aspect_ratio = :equal, #:equal
#widen=true,
ylims=(0.001,100),xlims=(0,100),
thickness_scaling = 1.25,
framestyle=:box,
size=(300,300)
)



The solution for the frame is framestyle=:box. The size=() option makes the plot squared (although if the limits of x and y are the same, this is not needed). To remove the 0 from the y axis you might change ylim to slightly more than 0:

This means that similar intervals in both axis will have the same apparent length. If the limits have the same interval sizes in both axis, that will do the trick. What was missing in your case is setting the x limits to be (0,100) to get the square plot.

1 Like