[Scilab-users] Fwd: plotxxyyy
Jens Simon Strom
j.s.strom at hslmg.de
Wed Oct 12 20:15:58 CEST 2016
Hallo Frieder,
If you insert
plot(x(M),y(M),'go')
after
//Writing measurement numbers
you get circle marks at the selected points to ease their correlation to the measurement number.
Kind regards
Jens
-----------------------------------------------------------
Am 12.10.2016 18:16, schrieb Jens Simon Strom:
> Hallo Frieder,
> You can independently combine stack and skip of the measurement
> numbers by the code below.
> //Plotting measurement numbers with optional gaps and optional stacking to avoid overlapping
> //Generating dummy measurement data x,y and plotting them
> dx=0.5:50;// increment of x
> x=cumsum(dx);
> y=sind(x);
> yspan=max(y)-min(y);
> nM=length(x);//number of measurements
> xdel();
> plot(x,y,'r')
> plot(x,y,'b+')
>
> //Input parameters for plotting the measurement numbers with optional gaps and stacking to avoid overlapping
> nstack=6;//maximum number of stacked measurement numbers
> hstack=0.1;//height of measurement number stack (relative to span). hstack=0: no stacking independent of nstack
> ybase=-1; //base ordinate for measurement numbers
> step=2;// step=1: no gap, step=2: every second measurement number, etc.
>
> //Writing measurement numbers
> M=1:step:nM;//opted measurement numbers
> for m=1:length(M)
> xstring(x(M(m)),ybase+(modulo(M(m),nstack))*hstack*yspan/nstack,string(M(m)))
> end
>
> "How can I move the lettering above the plot (or at least to the bottom, next to the x-axis)?"
> By data_bounds (see axes_properties in the help pages) you can enlarge the y-axis beyond the y data span at will.The y-level of the lettering is controlled by the input variable 'ybase' (see code above).
>
> Kind regards
> Jens
> ---------------------------------------------------------------------------------------------------------------------------------
>
> Am 12.10.2016 14:01, schrieb Frieder Nikolaisen:
>>
>> Hello everybody,
>>
>> I did solve the Problem with showing only 10 line numbers, by using IF.
>>
>> printer=1
>> for k=1:A_size(1,1) //Beschriftung
>> *if k>A_size(1,1)*(printer/10) then*
>> printer = printer + 1
>> xstring(x(k),y3(1),string(k))
>> // xstring(x,y,str,[angle,[box]])
>> end
>> set(handles.Anzeige, 'string', 'Diagrammbeschriftung' + string(k) + ' von' + string(A_size(1,1)))
>> end
>>
>> The line numbering is connected to the y-axis. How can I move the lattering aboth the plot (or at least the bottom, next to the x-axis)? (attached plot: subplot_with_line_number_2_tenth.gif)
>>
>> About Jens help:
>> I attached three plots: the stacks Picture are with the Code of Jens. Stacking is really nice, but I do not need every line number. With 921 data Points, it is already unreadable again. But thanks for your ideas, the Code is great for learningn anyway.
>>
>> Cheers
>> Frieder
>>
>> On 2016-10-12 11:48, Jens Simon Strom wrote:
>>
>>> Hello Frieder,
>>> Your plots look better now. You can avoid overlapping of measurement
>>> numbers by sawtooth stacking them. See example code below.
>>> xdel();
>>> //Generating dummy measurements x,y
>>> dx=0.5:50;
>>> x=cumsum(dx);
>>> y=sind(x);
>>> nM=length(x);//number of measurements
>>> plot(x,y,'r')
>>> plot(x,y,'b+')
>>> //Plotting the measurement numbers in stacks to avoid overlapping
>>> nstack=6;//number of stacked measurement numbers
>>> hstack=0.2;//height of measurement number stack (relative to window height)
>>> ybase=-0.9; //base ordinate for measurement numbers
>>> yspan=max(y)-min(y);
>>> for m=1:nM//measurement number
>>> xstring(x(m),ybase+(modulo(m,nstack)-1)*hstack*yspan/nstack,string(m))
>>> end
>>> Kind regards
>>> Jens
>>> ------------------------------------------------------------------------------------------------------------------------------
>>> Am 12.10.2016 10:52, schrieb Frieder Nikolaisen:
>>>>
>>>> Hello,
>>>>
>>>> thank you for all the feedback and help. It's really great.
>>>>
>>>> I used the idea of Jens Simon Strom combined with some help from
>>>> last week:
>>>>
>>>> //Datensätze
>>>> x1 = (A(:,1) - A(1,1)) * 24 * 3600;
>>>> y1 = A(:,y_1);
>>>> y2 = A(:,y_2);
>>>> y3 = A(:,y_3);
>>>> drawlater()
>>>>
>>>> subplot(3, 1, 1)
>>>> co = color("green");
>>>> plot2d(x1, y1, co);
>>>> a = gca();
>>>> b.font_color = co;
>>>> a.foreground = co;
>>>> ylabel(string(kT(y_1)),"color",co)
>>>> a.x_location = 'top';
>>>>
>>>> subplot(3, 1, 2)
>>>> co = color("blue");
>>>> plot2d(x1, y2, co);
>>>> b = gca();
>>>> b.font_color = co;
>>>> b.foreground = co;
>>>> ylabel(string(kT(y_2)),"color",co)
>>>> b.axes_visible(1) = "off";
>>>> //b.marings = [0.1 0.1 0.3 0.5];
>>>> //b.filled ="off";
>>>> subplot(3, 1, 3)
>>>> co=color("red");
>>>> plot2d(x1, y3, co);
>>>> c = gca();
>>>> c.font_color = co;
>>>> c.foreground = co;
>>>> //c.axes_visible(1) ="off";
>>>> ylabel(string(kT(y_3)),"color",co)
>>>> //xlabel(string('Zeit [Sekunden]'), co)
>>>> x= (A(:,1) - A(1,1)) * 24 * 3600;
>>>> for k=1:A_size(1,1) //Beschriftung
>>>> xstring(x(k),x(1),string(k)) // x(1) always 0
>>>> // xstring(x,y,str,[angle,[box]])
>>>> disp(x(1))
>>>> end
>>>> //c.marings = [0.1 0.1 0.5 0.3];
>>>> //c.filled ="off";
>>>>
>>>> drawnow()
>>>>
>>>>
>>>> The printed plots are attached. I did plot different paramters, as I can choose then in my GUI.
>>>> That works well:
>>>>
>>>> * Three plots, having the same x axis.
>>>> * x axis on the top and bottom
>>>> * Line *numbers Fitting the x axis*.
>>>>
>>>> That does not work:
>>>>
>>>> * showing a *few line numbers* only, for reading (best case:
>>>> Fitting the automatic shown times in sec
>>>>
>>>> Problem: I cannot tell, how many datapoints there are going to be.
>>>> So it mus be choosen automaticly.
>>>>
>>>> Best regards
>>>>
>>>> Frieder
>>>>
>>>> On 2016-10-11 21:04, Samuel Gougeon wrote:
>>>>
>>>> Hello,
>>>>
>>>> Le 11/10/2016 14:46, Rafael Guerra a écrit :
>>>>
>>>> Hi,
>>>>
>>>> I was not able to follow the whole discussion
>>>>
>>>> Neither did i,
>>>>
>>>> but concerning your subplot challenge: "/... I cannot add a
>>>> second x-axis in a subplot by newaxis(). How to add a
>>>> x-axis by using subplot?/"and your last example,
>>>>
>>>> Couldn't you add a 4^th subplot at the bottom in order to
>>>> plot the 2^nd x-axis (say by plotting only zeros)?
>>>>
>>>> .
>>>> Why not using drawaxis() as already suggested? drawaxis() is
>>>> made for this kind of situation.
>>>> In this thread, no logarithmic axis is involved. So i do to
>>>> catch the reason of ignoring drawaxis().
>>>>
>>>> By the way, IMO, a drawing of what exactly is required would be
>>>> clearer than hundred of lines of description, with schematic
>>>> curves, axes, arrows linking curves to their multiple axes in x
>>>> and y.
>>>>
>>>> BR
>>>> Samuel Gougeon
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> users mailing list
>>>> users at lists.scilab.org
>>>> http://lists.scilab.org/mailman/listinfo/users
>>
>>
>>
>> _______________________________________________
>> users mailing list
>> users at lists.scilab.org
>> http://lists.scilab.org/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20161012/1c6c6d20/attachment.htm>
More information about the users
mailing list