Lines vanishing on plot when rescaling axes

I am plotting four lines. When they are first plotted, they are all visible. However, after the axes are rescaled, one of the lines disappears. My code and the before and after rescalings can be seen below.
.
plot(xdata, ydata1, 'k')
hold on
plot(xdata, ydata2, '--k')
plot(xdata, ydata3, 'r')
plot(xdata, ydata4, '--r')
legend("1", "2", "3", "4")
xlim([0 0.3])
test1.jpg is before the rescaling, test2.jpg is after the rescaling.

Réponses (1)

KSSV
KSSV le 20 Avr 2022
Modifié(e) : KSSV le 20 Avr 2022
I don't think they are vanishing...they might be mixing up with the already existing line: Try:
plot(xdata, ydata1, 'k')
hold on
plot(xdata, ydata2, '--k')
plot(xdata, ydata3, 'r')
plot(xdata, ydata4, '*-b')
legend("1", "2", "3", "4")
xlim([0 0.3])

4 commentaires

I tried that, but it doesn't work. The line for ydata2 still vanishes. It only reappears if a line marker is applied to ydata2 as well.
KSSV
KSSV le 20 Avr 2022
Then go by marker.
Because of how close the lines are, I've been trying to avoid markers.
Also, doesn't being forced to used markers defeat the purpose?
VBBV
VBBV le 13 Avr 2023
Modifié(e) : VBBV le 13 Avr 2023
May be you are using the old unscaled data for
plot(xdata, ydata2, '--k') % check if ydata2 is old unscaled data or rescaled ???
while plotting the rescaled data for remaining ydata values. The code will still plot ydata2 but doesnt appear in plot due to scaling range chosen.. Check by using ylim after plotting rescaled data
ylim([0 1])

Connectez-vous pour commenter.

Produits

Version

R2020a

Modifié(e) :

le 13 Avr 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by