How to prevent plotted contents to spill outside of the axes lines

46 visualizaciones (últimos 30 días)
Mitsu
Mitsu el 8 de Ag. de 2021
Comentada: Yazan el 8 de Ag. de 2021
Using
set(gca, 'Layer', 'top')
I end up with this:
Is there a way to completely hide plotted contents that appear beyond the axes?
  4 comentarios
Mitsu
Mitsu el 8 de Ag. de 2021
Thank you for your comment, Yazan. I am aware that I can always change the size of markers and lines, but that is not what I asked. I made them very big in this example to make it obvious for the purpose of this question.
Yazan
Yazan el 8 de Ag. de 2021
The property SizeData of a scatter plot is related to the area of the marker. So assuming you specify a circular marker, Matlab will plot circles centered at the data with a radius that can be computed from SizeData. So, for each data point, find the radius of the circular marker, compute the edge points locations (horizontal and vertical extensions of the marker), see if they exceeded the axis limits and discard the data point if so. This is unnecessarily complex in my opinion given that you just need to resize the axes to solve the issue.

Iniciar sesión para comentar.

Respuestas (1)

DGM
DGM el 8 de Ag. de 2021
Editada: DGM el 8 de Ag. de 2021
One would think that the 'clipping' property of the axes object would take care of that, but I guess not.
Oof:
I don't know if that's a very practical approach, especially for as many markers as you have. It might be better to just adjust your axes limits a bit instead.

Etiquetas

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by