Why Isn’t One of Plots Shown?

1 visualización (últimos 30 días)
Rightia Rollmann
Rightia Rollmann el 2 de Mzo. de 2017
Editada: Adam el 2 de Mzo. de 2017
I have some questions regarding the code below
hax1 = axes('OuterPosition', [0 0 0.5 0.5]);
hax2 = axes('OuterPosition', [0.5 0.5 0.5 0.5]);
p1 = plot(1:10,rand(1,10), 'Color', 'b', 'parent', hax1)
hold on
p2 = plot(1:10,rand(1,10), 'Color', 'r', 'parent', hax1)
  1. Why isn’t p1 shown in hax1, although hold is on and both belong to hax1?
  2. How can I show both p1 and p2 on hax1? (I want to have p1 and p2 in separate lines and not in one line together (i.e., plot(x1,y1,x23) ,y2))
  3. Is there any way to specify a plot’s parent before plotting it? In the code above, I specified plots parents after entering the x and y coordinates, but I first want to specify plots parents and then later specify plots coordinates.

Respuesta aceptada

Adam
Adam el 2 de Mzo. de 2017
Editada: Adam el 2 de Mzo. de 2017
You need to use
hold( hax1, 'on' )
Every axes-related instruction you give should be to an explicit axes handle. Never just rely on the current axes otherwise you end up with issues like this.
Also I tend to use
plot( hax1, ... )
but it amounts to the same thing as what you did, it is all one single instruction so it isn't really after supplying the coordinates.

Más respuestas (0)

Categorías

Más información sobre Line Plots 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!

Translated by