[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Plot issues

From: James Sherman Jr.
Subject: Re: Plot issues
Date: Mon, 18 Jan 2021 00:25:11 -0500

On Sun, Jan 17, 2021 at 11:41 PM Blaz <> wrote:

I have a following simple code with two sine waves


I have two questions regardng the plot

1. Is there a way to print an index (1,2,3...) of a datapoint on the plot?
2. Is there a way on how to make the lines Bold or to increase thickness?
Plot help instruction do not work (or I am using it wrong). Any examples fro
both would be much appreciated.


Sent from:

Hi Blaz,

1) Yes, but there isn't a built in way, as far as I know.  Using a bit of a hack (I'm never great at manipulating cell arrays), you can use the text command to add text (in this case the indices) to specific points on the plot, like so:
indices = 1:length(t);
indices_cell = mat2cell(indices, 1, ones(1, length(t))); % there is probably a better way to make a cell array
indices_strings = cellfun(@num2str, indices_cell, "UniformOutput", false); % takes every number in the cell array and maps it to a string
text(t, x, indices_strings) % adds the strings to the coordinates (t,x) you may want to adjust them by adding or subtracting some value to make it look nicer?

2) Change the linewidth property using the plot command, like so:

Hope this helps,
James Sherman Jr.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]