Thread Subject: 'YScale','log',

Subject: 'YScale','log',

From: Gjergji

Date: 15 Jun, 2008 16:46:02

Message: 1 of 5

I would like to convert a graph from linear y-axis, to a
logarithmic y-axis. However, once that is done, one of the
vertical lines (which I use to indicate the required point)
disappears. See the image below:

http://img517.imageshack.us/img517/4937/weirdak0.jpg



My plotting code:

figure1 = figure('Color',[0.8 0.8 0.8]);
axes('Parent',figure1,'YScale','log','YMinorTick','on','YMinorGrid','on',...
    'FontSize',8,...
    'FontName','Verdana');
xlim([1 2.2]);
ylim([0 1000]);
box('on');
grid('on');
hold('all');



plot([0, k_Re], [Re_i, Re_i],'LineStyle','--','Color',[1 0 0]);
plot([k_Re,k_Re], [0, Re_i],'LineStyle','--','Color',[1 0 0]);
plot(x_Re,y_Re,'LineWidth',2,'Color',[0 0 1]);

% where k_Re = 2.081410
% Re_i = 200


xlabel('Correction factor
[k_R_e]','FontWeight','light','FontSize',8,'FontName','Verdana');
ylabel('Reynolds number
[Re]','FontSize',8,'FontName','Verdana');
title({'An empirical correction factor';'as a function of
fuselage Reynolds
number'},'FontWeight','bold','FontSize',8,'FontName','Verdana');




Any reason why this is happening?

Subject: 'YScale','log',

From: dpb

Date: 15 Jun, 2008 17:44:48

Message: 2 of 5

Gjergji wrote:
> I would like to convert a graph from linear y-axis, to a
> logarithmic y-axis. However, once that is done, one of the
> vertical lines (which I use to indicate the required point)
> disappears. ...
...
> figure1 = figure('Color',[0.8 0.8 0.8]);
> axes('Parent',figure1,'YScale','log','YMinorTick','on','YMinorGrid','on',...
...
> plot([0, k_Re], [Re_i, Re_i],'LineStyle','--','Color',[1 0 0]);
> plot([k_Re,k_Re], [0, Re_i],'LineStyle','--','Color',[1 0 0]);
> plot(x_Re,y_Re,'LineWidth',2,'Color',[0 0 1]);
...
> Any reason why this is happening?

Undoubtedly... :) (But I don't know why, otomh)

My question/suggestion would be why did you not use semilogy()?

--

Subject: 'YScale','log',

From: Matt Fig

Date: 15 Jun, 2008 17:55:04

Message: 3 of 5

Log plots can be tricky.

In your second call to plot, you try to plot a vertical line
from y = 0 to y = Re_i, but log10(0) = -Inf, so the line
ends up being a point at (k_Re,Re_i).

Try plotting from 1 instead.

Subject: 'YScale','log',

From: Matt Fig

Date: 15 Jun, 2008 19:06:02

Message: 4 of 5

This reproduces your log plot pretty closely.




Re_i = 200;
k_Re = 2.081410;
x_Re = 1.15:.1:2.15;
y_Re = (140.^(x_Re))*.00657;
figure1 = figure('Color',[0.8 0.8 0.8]);
axes('Parent',figure1,'YScale','log','YMinorTick','on','YMinorGrid',...
     'on','FontSize',8,'FontName','Verdana');
xlim([1 2.2]);
ylim([0 1000]);
box('on');
grid('on');
hold('all');
plot([0, k_Re], [Re_i, Re_i],'LineStyle','--',...
     'Color',[1 0 0]);
plot([k_Re,k_Re], [min(y_Re),
Re_i],'LineStyle','--','Color',[1 0 0]);
plot(x_Re,y_Re,'LineWidth',2,'Color',[0 0 1]);
xlabel('Correction factor [k_R_e]','FontWeight',...
       'light','FontSize',8,'FontName','Verdana');
ylabel('Reynolds number
[Re]','FontSize',8,'FontName','Verdana');
title({'An empirical correction factor';...
       'as a function offuselage Reynoldsnumber'},...
     'FontWeight','bold','FontSize',8,'FontName','Verdana');

Subject: 'YScale','log',

From: Gjergji

Date: 15 Jun, 2008 19:48:03

Message: 5 of 5

Nicely done...
Yeah that totally slipped my mind. Taking the minimum of
y_Re works great.

Thanks a lot. I appreciate it.

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Contact us at files@mathworks.com