plot range

View: New views
12 Messages — Rating Filter:   Alert me  

plot range

by orangensaft :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hallo, everyone,

is it possbile to plot two functions with seperate ranges in one plot? for example,
y=2*x*x, x =[0,2], y=-2x*x+16, x=[2,4].
Anyone has an idea?

Re: plot range

by Thomas Sefzick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

plot x<=2 ? 2*x*x : -2*x*x+16
or
plot x<=2 ? 2*x*x : 0/0 , x>=2 ? -2*x*x+16 : 0/0

for more information see the manual
http://www.gnuplot.info/docs/gnuplot.html
('gnuplot' - 'expressions' - 'operators' - 'ternary')
or type
help ternary
at the gnuplot prompt.

> hallo, everyone,
>
> is it possbile to plot two functions with seperate
> ranges in one plot? for example,
> y=2*x*x, x =[0,2], y=-2x*x+16, x=[2,4].
> Anyone has an idea?

Re: plot range

by orangensaft :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hello, thanks for your answer. At first it works. But the plot is one function, it means i can not plot them with two colors or with two titles. Do your have any suggestion for this?


Thomas Sefzick wrote:
plot x<=2 ? 2*x*x : -2*x*x+16
or
plot x<=2 ? 2*x*x : 0/0 , x>=2 ? -2*x*x+16 : 0/0

for more information see the manual
http://www.gnuplot.info/docs/gnuplot.html
('gnuplot' - 'expressions' - 'operators' - 'ternary')
or type
help ternary
at the gnuplot prompt.

> hallo, everyone,
>
> is it possbile to plot two functions with seperate
> ranges in one plot? for example,
> y=2*x*x, x =[0,2], y=-2x*x+16, x=[2,4].
> Anyone has an idea?

Re: plot range

by Thomas Sefzick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

just use my 2nd example ;-)

> hello, thanks for your answer. At first it works.
> But the plot is one function, it means i can not
> plot them with two colors or with two titles.
> Do your have any suggestion for this?
>
>> plot x<=2 ? 2*x*x : -2*x*x+16
>> or
>> plot x<=2 ? 2*x*x : 0/0 , x>=2 ? -2*x*x+16 : 0/0

and if you don't want this little gap between the
curves, increase the number of plot points:
set samples 1025

Re: plot range

by orangensaft :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

thanks, thomas, it is solved.

dashed line

by micmac :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear all,

I have an esthetic problem...
I have basically two curves which are more or less the same.. I want  
to plot them in a same graph with a dashed line..of two different  
colors...one color for each curve ...

so the best would be to have dashed lines which are a bit shifted  
(ideally in quadrature..)
is that possible???
can we set that? or do you have an idea of another trick?

thanks a lot,
Julien



-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Gnuplot-info mailing list
Gnuplot-info@...
https://lists.sourceforge.net/lists/listinfo/gnuplot-info

Re: dashed line

by orangensaft :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

As far as i know, dashed line with color is difficult. It may be possible with postscript. But i have never tried it. Thomas could have better suggestion.

micmac wrote:
Dear all,

I have an esthetic problem...
I have basically two curves which are more or less the same.. I want  
to plot them in a same graph with a dashed line..of two different  
colors...one color for each curve ...

so the best would be to have dashed lines which are a bit shifted  
(ideally in quadrature..)
is that possible???
can we set that? or do you have an idea of another trick?

thanks a lot,
Julien



-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Gnuplot-info mailing list
Gnuplot-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnuplot-info

Re: dashed line

by Thomas Sefzick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> I have an esthetic problem...
> I have basically two curves which are more or less
> the same.. I want to plot them in a same graph with
> a dashed line..of two different colors...one color for
> each curve ...
>
> so the best would be to have dashed lines which
> are a bit shifted (ideally in quadrature..)
> is that possible???

shifting the dashed pattern along the graph?
or defining two complementary dashed patterns?
don't think that's easy to do...

it depends on the 'terminal' you are using
how dashed lines are implemented.

in case of emulated dashed lines it may be
possible, but for the majority of terminals with
dashed lines capability it is left to the output
device (which may be a printer, plotter, or a
program) to produce dashed lines.

even if there would be some trick it would
apply to a specific terminal only.

> can we set that? or do you have an idea
> of another trick?

for plotting two functions i would combine
a solid and a dashed curve.
use the 'test' command to see which dashed
lines exist for the terminal you are using
and choose the appropriate line types.

Re: dashed line

by Thomas Sefzick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> or do you have an idea of another trick?

what you could do:
plot curve 1 solid, curve 2 solid, curve 1 dashed line

an example:

set xrange [-pi:pi]
set yrange [-1.1:1.1]
set term post col dash
set style line 1 lt 1 lc 2 lw 5
set style line 2 lt 3 lc 2 lw 5
set style line 3 lt 1 lc 1 lw 5
set out 'plot.ps'
plot sin(x) ls 1, 1.02*sin(x) ls 3, sin(x) not ls 2
set out



Re: dashed line

by orangensaft :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hallo, Thomas,

Is it possible to plot a straight line like x=3,  1<y<2, without using "set arrow"?

Re: dashed line

by Thomas Sefzick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Is it possible to plot a straight line like x=3,  1<y<2, without using "set arrow"?

yes, in parametric plotting mode, see 'help parametric'

but then all of your functions need to be specified as a
pair of x(t),y(t)-functions, e.g.:

instead of:

set xrange [-pi:pi]
plot sin(x)

it would be:

set parametric
set trange [0:1]
f(x)=x*2.*pi-pi ; # just for convenience
plot f(t),sin(f(t))

plus a vertical line (x=2, -0.7<=y<=0.5):

plot f(t),sin(f(t)), 2.,t*1.2-0.7

Re: dashed line

by Thomas Sefzick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Is it possible to plot a straight line like x=3,  1<y<2, without using "set arrow"?

gnuplot is able to plot functions and data.
a vertical line isn't a function, but it may be plotted by giving its two endpoints:

------------------------------------------------------------

set xrange [-pi:pi]
set yrange [-1.1:1.1]

# function plus
# 3 lines:
# from  3.0,-0.5 to  3.0,1.0
# from  2.0,-0.8 to  2.0,0.9
# from -1.0,-1.0 to -1.0,1.0

plot sin(x), "-" with lines
3.0 -0.5
3.0 1.0

2.0 -0.8
2.0 0.9

-1.0 -1.0
-1.0 1.0
e

------------------------------------------------------------