Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
linewidth control

Subject: linewidth control

From: Godzilla

Date: 16 Mar, 2009 02:17:01

Message: 1 of 3

Is it possible to more accurately control the linewidth of a plotted line?

I would really like to scale the width of the line to some fraction of the x-axis tick marks. For example, my ticks are 1-second spacing and I want draw a line whose width corresponds to 100 msec.

 

Subject: linewidth control

From: Miroslav Balda

Date: 16 Mar, 2009 19:11:01

Message: 2 of 3

"Godzilla " <godzilla@tokyo.edu> wrote in message <gpkcqt$9n5$1@fred.mathworks.com>...
> Is it possible to more accurately control the linewidth of a plotted line?
>
> I would really like to scale the width of the line to some fraction of the x-axis tick marks. For example, my ticks are 1-second spacing and I want draw a line whose width corresponds to 100 msec.

Hi,
One solution is here:

lw = 0.1; % linewidth in seconds
set(gca,'Units','pixels');
xlim = get(gca,'XLim');
dt = xlim(2)-xlim(1); % displayed time in seconds
pos = get(gca,'Position');
w = (pos(3)-pos(1))/dx*lw;
plot(t,fun(t),'Linewidth',w);

Hope it hepls.

Mira

Subject: linewidth control

From: Godzilla

Date: 17 Mar, 2009 02:15:04

Message: 3 of 3

"Miroslav Balda" <miroslav.nospam@balda.cz> wrote in message <gpm885$s28$1@fred.mathworks.com>...
> "Godzilla " <godzilla@tokyo.edu> wrote in message <gpkcqt$9n5$1@fred.mathworks.com>...
> > Is it possible to more accurately control the linewidth of a plotted line?
> >
> > I would really like to scale the width of the line to some fraction of the x-axis tick marks. For example, my ticks are 1-second spacing and I want draw a line whose width corresponds to 100 msec.
>
> Hi,
> One solution is here:
>
> lw = 0.1; % linewidth in seconds
> set(gca,'Units','pixels');
> xlim = get(gca,'XLim');
> dt = xlim(2)-xlim(1); % displayed time in seconds
> pos = get(gca,'Position');
> w = (pos(3)-pos(1))/dx*lw;
> plot(t,fun(t),'Linewidth',w);
>
> Hope it hepls.
>
> Mira

Thanks. Just what I was looking for.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us