In order to illustrate a Cauchy problem for first order ode with infinite family of solutions, I would plot the parametrized solution and having the possility of control the value the parameter through a slider.
To be complete the Cauchy problem is y'=sqrt(|y|), y(0)=0, and the parametric solution is y_c(x):={0, if c=>x; (x-c)^2/4, if x=>c}.
So I would get a plotting of y=y_c(x) with a slider to control the value of c.
Thank you.
You can use with_slider_draw in wxMaxima to do this.
Y(c,x) := if c>x then 0 else (x-c)^2/4;
with_slider_draw(
c, /* the name of the variable to attach to the slider */
makelist(i,i,0,1,0.1), /* a list of values that the variable can have */
explicit(Y(c,x), x, 0, 2) /* plot the function */
)$
In wxMaxima, click on the graph and then click on the Play button on the toolbar to play the animation,
or use the slider on the tool bar to change the value of c.
You could use Maxima from within the Sage notebook and resort to the interact command. See also Sage's interface to Maxima.
Related
I tried the following code in my script, but it doesn't work, becuase of error: Cannot use 'plotshape' in local scope.
for i = 0 to counter_buy
plotshape(high + counter_buy, style = shape.circle, location=location.absolute, color = color.green, size = size.auto)
What I'm trying to do:
There is a counter in my script (counter_buy) I want to draw a circle for each value of "1" above the current bar. So if the counter is "3" I want to draw 3 circles above the current bar. Each circle above the other, like this example:
o
o
o
BAR
Is there a way to archive this?
Thanks, Mag
You can't use plot statements in for loops or any other local block in a script. There are 2 ways to go about this, depending on your requirements: either with multiple plotshape() calls or with labels.
Is it important that you see those circles on ALL the dataset's bars where they should appear or are you OK with only the last ~50 occurrences showing?
What's the max value for counter_buy?
thanks for your response. My solution were counters in my script that gets higher or lower at specific situations, like crossovers. Then I plot arrows above or below the current bar, with values of my counters.
plotarrow(counter1, colorup=color.green, colordown=color.red, transp=30, maxheight=50)
plotarrow(counter2, colorup=color.blue, colordown=color.blue, transp=30, maxheight=30)
When a graph is very wide I want to show the y-axis values also on the right side of the graph so it becomes easier to read the corresponding values of the lines.
I know how to duplicate the left axis to the right. And when the graph is created I use ActYscl to set the range of scale nr 0 (left) to scale nr 1 (right). This works when the graph is created and also the zoom and pan function work on both y-scales. However, when I use the Autoscale function of the Graph Pallet, only the initial axis is scaled (probably because the graph data are only linked to the original axis).
Is there a way to make the autoscale function work for both y-axis at the same time?
Charts and graphs have an Autoscale Range Change event. Use an event structure to catch this event and update the range of the duplicate scale to match the first one:
I've used a chart for this example as it's simpler, but it should work the same for a graph. Of course you need a way of telling the event loop when to exit; I've used the Value Changed event of the stop button. If your application uses an event-driven structure anyway, you should just be able to add the autoscale event to your existing event loop.
I want to use interactive plots in R to be able to select x intervals in plots, i have tried plot.ly and ggvis and it seems that the mouse click on the plot followed by horizontal drag, used for zooming is exactly what i want, but zoom would have to be disabled and the [x start, x end] values must be returned to R. Any ideas if this is possible, and if so, how?
I tried to make tooltip function available with static_output (without shiny).
You can check my fork (https://github.com/lujiacn/ggvis
), enable the tooltip by default, in Rstudio and output html widget.
The way is put tooltip content in one variable called "tooltip". If no "tooltip" variable, wills show the all values linked to the data.
I have on ODE of the form $\frac{dy}{dx}=f(x,y)$ that I managed to plot its solution in Matlab.
I want to add "direction of progress arrows" to the curves.
The curves illustrated below are the paramteric plot of x(t) and y(t), each having 1500 steps.
The black arrow seen on left has been inserted using the "Insert Arrow" option from the figure's window.
I want to add arrows like those in the black and white picture attached.
Is there any way to do it? Any help would be appreciated.
Not sure if you ever figured this out, however, one solution, though not elegant, could be to use the Plot with Direction Function from the MATLAB FEx.
After computing your ODE solution, you could take various points and use the above Plot with Direction function from the FEx. Below is some pseudo code which describes what I am talking about.
[x_sol, y_sol] = ODE_METHOD(#fcn,...);
x_Points4Arrow = x_sol([...]);
y_Points4Arrow =
% Plot ODE solution
for ind = 1:numel(y_Points4Arrow)
| hold on
| Plot With Direction(x_Points4Arrow(ind), y_Points4Arrow(ind));
| hold off
end
% Modify axes and anything else
You could even modify that function to take in the Line Properties - or just modify the code if you only want one color.
Maxima plotting in a loop, must shut one plot to see the next one. Iam working in windows environment, but in linux will the function plotted in one view.
For example this function :
for d:0.1 thru 1 step 0.1 do
draw2d(explicit(x^d,x,0,1));
I have also tried this:
set_plot_option(['plot_format, 'gnuplot_pipes]);
But this didnt solve it. Is there an option, where i can set the plotting in one view?
Thank you.
You could make a list of curves in the loop and plot them all on a single graph. You can use a loop or makelist to build the curve list.
makelist(x^d, d, 0, 1, 0.1);
plot2d(%, [x, 0, 1]);
If you're using wxMaxima, you can the with_slider_draw function to animate the plot:
with_slider_draw(
d, /* the name of the variable to attach to the slider */
makelist(i,i,0,1,0.1), /* a list of values that the variable can have */
explicit(x^d, x, 0, 1) /* plot the function */
)$
If you prefer plot2d arguments, use with_slider to do the same thing:
with_slider(
d,
makelist(i,i,0.1,1,0.1),
[x^d], [x,0,1]
);
Click on the graph and then use the Play button on the toolbar to play
the animation. You can use the slider on the toolbar or your mouse wheel to move back and forth
between animation frames. You can even save the animation as an animated gif by right-clicking the plot and choosing Save Animation.