How does I bring the line plot in front of the bar?

179 visualizaciones (últimos 30 días)
Kwanghun Choi
Kwanghun Choi el 25 de Feb. de 2019
Editada: Adam Danz el 5 de Dic. de 2021
I am makeing the graph to illustrate some information with plot function and bar function.
Problem is the line made by plot function is always back of the bar, so some part of line is hided like a image below.
It is possible to control the size of axis to make not to be overlaped, but I do not want to do that.
How can I bring the line in front of the bar?

Respuesta aceptada

Kevin Phung
Kevin Phung el 25 de Feb. de 2019
Use uistack();
a = plot(x,y) %let a be the handle to plot 1
b= plot(x2,y2) %let b be the handle to plot 2
uistack(a,'top') %you can also do uistack(b,'bottom')
  1 comentario
Adam Danz
Adam Danz el 5 de Dic. de 2021
Editada: Adam Danz el 5 de Dic. de 2021
As of Matlab R2021b, uistack does not work with yyaxis since the objects are assigned to different rulers.

Iniciar sesión para comentar.

Más respuestas (1)

Jakub Schneider
Jakub Schneider el 25 de Nov. de 2020
When using multiple y axis plot (yyaxis left and yyaxis right) the yyaxis right plot is on the top. So just switch left to right and the line will be over the bars.
  1 comentario
Jakob Weis
Jakob Weis el 8 de Jun. de 2021
When using two y-axes, simply switching the data/axes is rarely an option. The primary dataset has to go on the primary/left axis and the secondary dataset on the secondary right/axis.
Here's a workaround for this case: https://www.mathworks.com/matlabcentral/answers/280015-draw-stack-order-for-yyaxis

Iniciar sesión para comentar.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by