two graphs in one plot with different xranges

  • Follow


I'd like to have a plot of some data with a horizontal line, so I do

plot 'x', 1.8

which plots the file 'x' for me and the horizontal line at y = 1.8.
All is good, the file 'x' is:

1    1
2    2
3    1
4    2.2
5    1.5
6    1.7
7    2.0
8    2.1

Now I'd like to have the horizontal line not go from 1 to 8 which is
the default xrange calculated by gnuplot from the datafile, but I'd
like the horizontal line to stretch between 5 and 8 only. Note that
the xrange for the whole plot should remain the default one, from 1 to
8, only I'd like to have the horizontal line go from 5 to 8 only.

I could create a second datafile 'y' with the content

5 1.8
8 1.8

and then

plot 'x', 'y' w l

but something tells me it should be possible to just limit the domain
of the constant function y = 1.8 to 5 - 8 while keeping the xrange of
the whole plot the same as without including the constant, i.e. 1 - 8.

I checked the manual but xrange and yrange seem to be global and not
on a per graph basis, similarly the syntax "plot [x:y] 'file1',
'file2', 'file3'" defines the range [x:y] globally for all graphs on
the plot and having it on a per graph basis is not possible (or so it
seems to me).

So how would I do this?

Cheers,
Daniel
0
Reply fetchinson (371) 2/13/2010 2:54:57 PM

Hi!

Daniel wrote:
> I'd like to have a plot of some data with a horizontal line, so I do
> 
> plot 'x', 1.8

> Now I'd like to have the horizontal line not go from 1 to 8 which is
> the default xrange calculated by gnuplot from the datafile, but I'd
> like the horizontal line to stretch between 5 and 8 only. Note that
> the xrange for the whole plot should remain the default one, from 1 to
> 8, only I'd like to have the horizontal line go from 5 to 8 only.


plot 'datafile', (x>=5 ? 1.8 : 1/0)

HTH
Stefan
0
Reply Stefan 2/13/2010 3:38:07 PM


> > > I'd like to have a plot of some data with a horizontal line, so I do
>
> > plot 'x', 1.8
> > Now I'd like to have the horizontal line not go from 1 to 8 which is
> > the default xrange calculated by gnuplot from the datafile, but I'd
> > like the horizontal line to stretch between 5 and 8 only. Note that
> > the xrange for the whole plot should remain the default one, from 1 to
> > 8, only I'd like to have the horizontal line go from 5 to 8 only.
>
> plot 'datafile', (x>=5 ? 1.8 : 1/0)

Thanks a lot, exactly what I needed!

Cheers,
Daniel


0
Reply Daniel 2/13/2010 3:55:52 PM

2 Replies
690 Views

(page loaded in 0.047 seconds)

Similiar Articles:













7/21/2012 6:12:15 PM


Reply: