Sorry for (week-end) delay. Here is more or less what I did (I don’t include all the code, just the essential parts).
Here is what I did
Note: at the outset, I have already defined 3 functions: uₒ
, uₒ_c
, and uₒ_
which depend on temperature in a temperature span T_span
.
plot(T_span.-273.15,uₒ.(T_span),...)
plot!(T_span.-273.15,uₒ_c.(T_span),...
plot!(T_span.-273.15,uₒ_.(T_span),...)
plot!(
T_span.-273.15, [uₒ.(T_span), uₒ_c.(T_span),uₒ_.(T_span)], ...
xlim=(0,100),ylim=(1.165,1.192),
frame=:box,
yticks=false,
inset=bbox(0.143,0.47,0.35,0.35),
subplot=2
)
Some “recent frustrations” and (unrealistic?) suggestions…
Things in documentation that confused me
- At first, I didn’t know where to find the information in the documentation for Plots.jl.
If I search Plots.jl
and open the
page, attempt to find the inset
information by:
-
typing in inset
in the search box – now luck
-
do Ctrl+f
in the browser, and searched for inset
. Again, now luck, because the browser search function only search in the active window, i.e., in the Tutorial
up until (but not including) Series Types
.
-
your suggstion of inset_subplots
helped somewhat, but what really helped is the link to Layouts . Plots
.
Still, inset_subplots
does not occur in the plot
command… it is possible that inset_subplots
really means "the range of commands from inset
to subplot
?? That is, however, not obvious to me.
NOTE: this problem I have with search is not unique for Plots.jl
.
- Somewhat confusing argument list?
# The call is `bbox(x, y, width, height, origin...)`, where numbers are treated as
# "percent of parent"
This is somewhat confusing… the numbers (x
, y
, width
, height
) are not “percent of parent” (a number from 0-100), but fraction of parent (range: 0-1).
So my understanding of these numbers are:
-
x
, y
gives the coordinates of the inset relative to the upper left corner of the parent figure, which is position (0,0), with coordinate axes going downwards (x
) and to the right ( y
), and where the lower right corner of the parent plot is in position (1,1).
-
width
, height
specify the width and height of the inset in fraction of the parent plot window.
-
Is it somewhat confusing the the first coordinate of x
, y
relates to the vertical position, while the first of width
, height
relates to horizontal size? More logical with x
, y
, height
, width
? Perhaps.
-
the origin
argument is not really explained. But from examples, I assume that it is possible with two arguments, and that the purpose is to define how the inset is positioned relative to the inset origin specified by x
, y
. Where the default is that the inset origin is the upper left corner of the inset, so possible origin
commands are :bottom
, :right
, and similar.
- What does the
subplot
command do? Do I have to set the subplot = 2
if I have a single parent plot, i.e., without subplots?
Could the inset work in a simpler way?
Perhaps. The plot
command may get somewhat convoluted for complex plots with insets.
Would it be possible to do my plot above in the following way?
plot(T_span.-273.15,uₒ.(T_span),...)
plot!(T_span.-273.15,uₒ_c.(T_span),...
fig_parent = plot!(T_span.-273.15,uₒ_.(T_span),...)
followed by:
fig_sub = plot(T_span.-273.15, [uₒ.(T_span), uₒ_c.(T_span),uₒ_.(T_span)], ...
xlim=(0,100),ylim=(1.165,1.192),
frame=:box,
yticks=false)
followed by:
plot!(fig_parent,
fig_sub,
inset=bbox(0.143,0.47,0.35,0.35),
subplot=2
That way, the plot command holding the inset
command itself becomes relatively simple, while it is still possible to created complex plots for the parent plot and the inset.
OK – I have no idea whether this is possible from the architecture of Plots
…