Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.graphics.apps.gnuplot > #784 > unrolled thread

plot a function using solid line between [-pi, pi] while dashed line extended a little on both side

Started bySteven Du <stevendduu@gmail.com>
First post2011-12-25 21:36 -0800
Last post2011-12-26 22:09 -0800
Articles 3 — 2 participants

Back to article view | Back to comp.graphics.apps.gnuplot


Contents

  plot a function using solid line between [-pi, pi] while dashed line extended a little on both side Steven Du <stevendduu@gmail.com> - 2011-12-25 21:36 -0800
    Re: plot a function using solid line between [-pi, pi] while dashed line   extended a little on both side Ingo Thies <ingo.thies@gmx.de> - 2011-12-26 09:36 +0100
      Re: plot a function using solid line between [-pi, pi] while dashed line extended a little on both side Steven Du <stevendduu@gmail.com> - 2011-12-26 22:09 -0800

#784 — plot a function using solid line between [-pi, pi] while dashed line extended a little on both side

FromSteven Du <stevendduu@gmail.com>
Date2011-12-25 21:36 -0800
Subjectplot a function using solid line between [-pi, pi] while dashed line extended a little on both side
Message-ID<b3b49e0f-e0af-49a3-8940-7697491a1ef3@37g2000prc.googlegroups.com>
Hello:

I need to draw a -sinx function using solid line between [-pi, pi]
while dashed line extended.   The dashed line to show that the
function will be extended infinitely on both side, not stopped from -
pi  to pi.



How to plot like that?  Thanks.

Steve.


Here is the script:
set term postscript eps enhanced

set key 3,1 title ''             # title to key!

set key spacing 1.3

set title "- sin(x)"      # note newline!
set xlabel 't'
set ylabel ''

set output "1.2.a.eps"


set xrange [-1.2 * pi : 1.2 * pi]
set yrange [-1 : 1]

# set grid

set xzeroaxis lt -1
set yzeroaxis lt -1

set border 0

set xtics axis
set ytics axis

set ytics scale 1

set xtics ('-T/2' -pi, 'T/2' pi)

plot -1 * sin(x) title " -sin(x)" with line 1

[toc] | [next] | [standalone]


#785 — Re: plot a function using solid line between [-pi, pi] while dashed line extended a little on both side

FromIngo Thies <ingo.thies@gmx.de>
Date2011-12-26 09:36 +0100
SubjectRe: plot a function using solid line between [-pi, pi] while dashed line extended a little on both side
Message-ID<9lqpvsFu83U1@mid.individual.net>
In reply to#784
Hello Steven and happy Christmas!

> I need to draw a -sinx function using solid line between [-pi, pi]
> while dashed line extended.   The dashed line to show that the
> function will be extended infinitely on both side, not stopped from -
> pi  to pi.

I am not up to date whether gnuplot now has an intrinsic option for 
that. However, the standard solution has ever been to define two 
truncated functions. Let sin(x) be your function to be plotted. Then define

fin(x) = abs(x)<=pi ? sin(x) : 1/0
fout(x)= abs(x)>pi  ? sin(x) : 1/0

For the full description, see the gnuplot.pdf and look for "ternary" in 
the "Operators" section (p.29 in my version, but varies a little due to 
updates of the document).

The term 1/0 gives an unplottable value which ist simply skipped by 
gnuplot. Nowadays, also NaN (not a number) can be used directly. Now 
plot as follows (I skipped your other definitions here):

plot fin(x) w l lt 1, fout(x) w l lt 2

Instead of linetypes 1 and 2 you can, of course, also define linestyles, 
one with solid (linetype 1), and one with dashed (lt 2) shape. If all 
plots are the same colour and the dashed line is not wider than the 
solid one (i.e. it will be hidden by the solid line), you can skip the 
definition of fout entirely and use your sin(x) function directly.

HTH,

Ingo

[toc] | [prev] | [next] | [standalone]


#791

FromSteven Du <stevendduu@gmail.com>
Date2011-12-26 22:09 -0800
Message-ID<3812b218-47fb-42fa-8d6a-31b262b90e0d@f15g2000yqo.googlegroups.com>
In reply to#785
Hello Ingo:

Happy holidays!

I tested what you said and it works!

Steve


On Dec 26, 12:36 am, Ingo Thies <ingo.th...@gmx.de> wrote:
> Hello Steven and happy Christmas!
>
> > I need to draw a -sinx function using solid line between [-pi, pi]
> > while dashed line extended.   The dashed line to show that the
> > function will be extended infinitely on both side, not stopped from -
> > pi  to pi.
>
> I am not up to date whether gnuplot now has an intrinsic option for
> that. However, the standard solution has ever been to define two
> truncated functions. Let sin(x) be your function to be plotted. Then define
>
> fin(x) = abs(x)<=pi ? sin(x) : 1/0
> fout(x)= abs(x)>pi  ? sin(x) : 1/0
>
> For the full description, see the gnuplot.pdf and look for "ternary" in
> the "Operators" section (p.29 in my version, but varies a little due to
> updates of the document).
>
> The term 1/0 gives an unplottable value which ist simply skipped by
> gnuplot. Nowadays, also NaN (not a number) can be used directly. Now
> plot as follows (I skipped your other definitions here):
>
> plot fin(x) w l lt 1, fout(x) w l lt 2
>
> Instead of linetypes 1 and 2 you can, of course, also define linestyles,
> one with solid (linetype 1), and one with dashed (lt 2) shape. If all
> plots are the same colour and the dashed line is not wider than the
> solid one (i.e. it will be hidden by the solid line), you can skip the
> definition of fout entirely and use your sin(x) function directly.
>
> HTH,
>
> Ingo

[toc] | [prev] | [standalone]


Back to top | Article view | comp.graphics.apps.gnuplot


csiph-web