How Does SeriesIndex Work with LineStyleOrder?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Paul
el 1 de Sept. de 2024
My interpretation of SeriesIndex is that it controls the color and style of a line based on the ColorOrder and the LineStyleOrder properties of the axes.
figure;
ax = gca;
ax.LineStyleOrder = {'--x','--o','--*'};
get(gca,'LineStyleOrder')
plot(1:3,1:3,SeriesIndex=2),axis padded
I did not expect the line to be solid without a marker.
The LineStyleOrder has changed back to the default?
get(gca,'LineStyleOrder')
It turns out that "hold" must be called after setting the LineStyleOrder and before the plot
figure;
ax = gca;
ax.LineStyleOrder = {'--x','--o','--*'};
hold on
plot(1:3,1:3,SeriesIndex=2),axis padded
ax.LineStyleOrder
However, according to LineStyleOrder the need to call 'hold' prior to plot() should only apply for releases prior to 2019b.
Is the doc in error or am I misreading it?
5 comentarios
dpb
el 1 de Sept. de 2024
Editada: dpb
el 1 de Sept. de 2024
I don't disagree about the doc with that new(ish at least) section regarding the order; it reads as if the writer of the documentation (who undoubtedly was not the developer) did expect the revised line order to begin with the value set, not connecting the behavior of HG2 with respect to what the 'NextPlot' property does.
Only that I knew already that unless 'NextPlot' is not 'replace' the axes properties are reset such that could check that setting the 'LineStyleOrder' did not also change its state was I able to infer that "continue" in that context had to imply that hold on had to have been executed in order to effect the described behavior with respect to continuation of the numbering sequence/style and that even if you were to change existing lines by the order vector index, unless hold on were set a new line would still reset the axes, wiping out the existing lines. From that I inferred the "continue" had to be in conjunction or the described behavior would not occur.
I wonder if, indeed, the intention with whatever was, specifically, changed in R2019b isn't actually implemented as what was intended or the explanation is just murky/garbled in not actually describing what the intended behavior is supposed to be.
It is probably worth a bug/support request asking for both clarification in intent/documentation if behavior is as intended or as a bug if it is really supposed to reset the order and not revert back to default when user does set an order vector -- or that it is, indeed, implied/required for the user to call hold on if wants the changed order to "stick".
Respuesta aceptada
Sandeep Mishra
el 2 de Sept. de 2024
Hi Paul,
I ran the provided code snippet and observed the similar results.
I found a way to set the ‘LineStyleOrder’ property of the axes without using the ‘hold’ function to get the desired result. You can set the property using the following code snippet:
% Setting LineStyleOrder property for 'ax' axis
ax.LineStyleOrder = linestyleorder({'--x','--o','--*'});
This method should allow you to set the ‘LineStyleOrder’ of the axes and achieve the expected result.
Please refer to the below documentation for more information on ‘linestyleorder’ property: https://www.mathworks.com/help/releases/R2024a/matlab/ref/linestyleorder.html
I hope this helps!
3 comentarios
dpb
el 2 de Sept. de 2024
Editada: dpb
el 2 de Sept. de 2024
@Paul, thanks for the additional input/testing/spelunking. For various reasons, I'm still using R2021b here and haven't taken the time to install a later version (given the slow bandwidth of connections in rural America, it takes in the hours time frame any more with the explosion in size and with no automagic restart, it's a far thing from certain it will complete the first time).
Más respuestas (0)
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!