Discussion:
add vertical line to plot2d
Tamas Papp
2014-08-05 16:24:58 UTC
Permalink
Hi,

How can I add a (preferably dashed or dotted) vertical line to a 2d plot
at a given value? Eg add a vertial line at x=%pi to

plot2d([sin(x)],[x,0,2*%pi]);

I thought of using [discrete, ...] but then I don't know how to
calculate the starting and ending y in a simple way (obviously in the
example I could, but I am thinking about general plots).

Best,

Tamas
Gunter Königsmann
2014-08-05 16:57:14 UTC
Permalink
The draw package would even provide you with lines as graphical objects. But AFAIK neither of the graphics packages returns a list of the values that are to be plotted even if the adaptive plotting routine will construct one and pass the points to gnuplot.

One could tell solve to generate a list of x values with diff(f(x),x)=0 and then do a apply(max, list). But there might be equations where the diff or the solve will fail.
Post by Tamas Papp
Hi,
How can I add a (preferably dashed or dotted) vertical line to a 2d plot
at a given value? Eg add a vertial line at x=%pi to
plot2d([sin(x)],[x,0,2*%pi]);
I thought of using [discrete, ...] but then I don't know how to
calculate the starting and ending y in a simple way (obviously in the
example I could, but I am thinking about general plots).
Best,
Tamas
------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls.
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
_______________________________________________
Maxima-discuss mailing list
https://lists.sourceforge.net/lists/listinfo/maxima-discuss
--
Diese Nachricht wurde von meinem Mobiltelefon mit Kaiten Mail gesendet.
Gunter Königsmann
2014-08-05 17:23:14 UTC
Permalink
Did try to implement the algorithm:


x_start:-10;
x_end:10;

f(x):=x^2-x^4;
s:solve(diff(f(x),x)=0);

ListOfInterestingX:[]$
len: length(s)$

for i:1 thru len do
if is(at(x,s[i])>x_start) and is(at(x,s[i])<x_end) then
push(at(x,s[i]),ListOfInterestingX);

yValuesToLookAt:append(
makelist(f(i),i,ListOfInterestingX),
[f(x_start),f(x_end)]
);

Maximum=apply(max,
yValuesToLookAt
);
Minimum=apply(min,
yValuesToLookAt
);

But there might be curves that are less benign than my f(x).


Kind regards,

Gunter.
Jaime Villate
2014-08-06 14:54:11 UTC
Permalink
Post by Tamas Papp
How can I add a (preferably dashed or dotted) vertical line to a 2d plot
at a given value? Eg add a vertial line at x=%pi to
plot2d([sin(x)],[x,0,2*%pi]);
The simplest way I can think of is (I don't know if that's what you want):

plot2d([sin(x),[discrete,
[[%pi,0]]]],[x,0,2*%pi],[style,lines,points],[point_type,plus],[color,blue,black],[legend,false]);

Jaime
Adam
2014-08-06 15:30:54 UTC
Permalink
Post by Tamas Papp
Hi,
How can I add a (preferably dashed or dotted) vertical line to a 2d plot
at a given value? Eg add a vertial line at x=%pi to
plot2d([sin(x)],[x,0,2*%pi]);
I thought of using [discrete, ...] but then I don't know how to
calculate the starting and ending y in a simple way (obviously in the
example I could, but I am thinking about general plots).
Best,
Tamas
------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls.
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
You can also use grid , like here :

Loading Image...

or imulses :

https://commons.wikimedia.org/wiki/File:Comb.svg


HTH

Adam

http://commons.wikimedia.org/wiki/Category:Images_with_Maxima_CAS_source_code
Fred Senese
2014-08-27 05:47:17 UTC
Permalink
Post by Tamas Papp
Hi,
How can I add a (preferably dashed or dotted) vertical line to a 2d plot
at a given value? Eg add a vertial line at x=%pi to
plot2d([sin(x)],[x,0,2*%pi]);
I thought of using [discrete, ...] but then I don't know how to
calculate the starting and ending y in a simple way (obviously in the
example I could, but I am thinking about general plots).
Best,
Tamas
--------------------------------------------------------------------------
----
Post by Tamas Papp
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls.
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?
id=153845071&iu=/4140/ostg.clktrk
You could plot it first without the vertical line to get the start and
ending y (-1 to 1 here), and then do something like

plot2d([sin(x), [parametric, %pi, t, [t, -1, 1]]],[x,0,2*%pi],
[style,lines,dots],[color,blue,black],
[legend, false]);

Loading...