Effacer les filtres
Effacer les filtres

An error occurred while trying to modify linewidth

5 vues (au cours des 30 derniers jours)
Maria
Maria le 29 Sep 2014
Modifié(e) : Stephen23 le 29 Sep 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

Réponse acceptée

Stephen23
Stephen23 le 29 Sep 2014
Modifié(e) : Stephen23 le 29 Sep 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])

Plus de réponses (1)

Maria
Maria le 29 Sep 2014
Many thanks for the answer!
-Maria

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by