Reputation: 857
I am trying to plot the graph of the inverse function to y=xe^x, where the plot above y=-1 is a solid line, and below is a dashed line. I would like to label the solid and dashed lines separately, but they appear on top of each other. How can I get around this?
Here is my code:
set multiplot
set parametric
set style arrow 1 head filled size char 1.5,20,50
set arrow 1 from -4.1,0 to 4.1,0 heads
set arrow 2 from 0,-4.1 to 0,4.1 heads
set trange[-4:4]
set xrange[-4:4]
set yrange[-4:4]
set xlabel "x"
set ylabel "y"
unset border
set xtics axis format " "
set ytics axis format " "
set arrow from -exp(-1),-1 to -exp(-1),0 nohead lt 3
set arrow from -exp(-1),-1 to 0,-1 nohead lt 3
set label "$e^{-1}" at -exp(-1),0.2
set label "-1" at 0.1,-1
plot [-1:4] t*exp(t),t title '$W_{0}(x)'$ lt rgb "black"
plot[-4:-1] t*exp(t),t lt 3 title '$W_{-1}(x)$'
which produces this figure:
https://i.sstatic.net/dylom.jpg
Upvotes: 1
Views: 1612
Reputation: 7627
They appear on top of each other because you're plotting twice (i.e. you're using the plot
command twice). Try the following conditional plot:
plot [-4:4] t*exp(t),(t < -1 ? t : 1/0) title '$W_{0}(x)$' lt rgb "black", \
t*exp(t),(t > -1 ? t : 1/0) lt 3 title '$W_{-1}(x)$'
You don't need multiplot
with the above.
Upvotes: 2