Borrar filtros
Borrar filtros

Adding a line to a plot without normalized coordinates

3 visualizaciones (últimos 30 días)
Chmical
Chmical el 10 de Mzo. de 2013
I am creating a scatter plot and I would like to add a line to the plot based on a y value. The y axis is not fixed and the line is specific to a value. How do I add a line to the plot?
example plot: scatter([0 10 20 30 40],[3 5 3 2 9]);
something like: line([0 40],[15 15], 'Color','r')
where line would go across the whole plot at 15 on the y and be red in color

Respuesta aceptada

Sven
Sven el 10 de Mzo. de 2013
Editada: Sven el 10 de Mzo. de 2013
You were so close:
figure
scatter([0 10 20 30 40],[3 5 3 2 9]);
hold on
plot([0 40],[15 15],'-', 'Color','r')
If you really wanted to use line(), you can do so, but you need to set its colour after it's been created:
figure
scatter([0 10 20 30 40],[3 5 3 2 9]);
hold on
h = line([0 40],[15 15])
set(h,'Color','r')

Más respuestas (1)

Chmical
Chmical el 11 de Mzo. de 2013
Thanks alot Sven. worked great...

Categorías

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