An error occurred while trying to modify linewidth

6 visualizaciones (últimos 30 días)
Maria
Maria el 29 de Sept. de 2014
Editada: Stephen23 el 29 de Sept. de 2014
Hi all,
I have tried to modify the linewidth as follows:
plot(t,means(k,:)*10^13,color{c},linewidth(c)),
where color ={'b',':b','k',':k','r',':r'}; linewidth = [0.5,3,0.5,3,0.5,3];
This works correctly without linewidth but when linewidth is added I get an error: ??? Error using ==> plot Attempt to modify a property that is read-only. Object Name : line Property Name : 'BeingDeleted'.
Could someone please let me know what I am doing wrong, and how the linewidth can be modified?
Thanks, Maria

Respuesta aceptada

Stephen23
Stephen23 el 29 de Sept. de 2014
Editada: Stephen23 el 29 de Sept. de 2014
The documentation for the plot command states that you can set the LineSpec immediately after X and Y value arrays, which is why this works in your loop:
plot(t,means(k,:)*10^13,color{c})
because color{c} defines a LineSpec value (in your case, a color). According to the documentation the LineSpec can be any of "line style, marker symbol, and colorstring". Notice that this list does not include line width.
If you read the only section of the documentation that mentions line widths, you will see that this occurs under the section titled "Name-Value Pair Arguments". Name-Value Pairs are often used in MATLAB to enter optional arguments for many functions. You can read more information in the plot documentation.
For the sake of completeness, this is an example that the plot documentation contains, which includes changing the line width:
x = -pi:pi/10:pi;
y = tan(sin(x)) - sin(tan(x));
figure
plot(x,y,'--gs',...
'LineWidth',2,...
'MarkerSize',10,...
'MarkerEdgeColor','b',...
'MarkerFaceColor',[0.5,0.5,0.5])

Más respuestas (1)

Maria
Maria el 29 de Sept. de 2014
Many thanks for the answer!
-Maria

Categorías

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