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:
one scatter plot with 2 x axis and 2 y axis, one of the x axis being a function of the first x axis

Subject: one scatter plot with 2 x axis and 2 y axis, one of the x axis being a function of the first x axis

From: Iris

Date: 28 Apr, 2013 23:27:10

Message: 1 of 1

Hello to all!
I'm trying to do a Hertzsprung-Russell diagram like this one: http://en.wikipedia.org/wiki/File:HRDiagram.png

If you see, the temperature (top x axis) is not a linear function of the color (bottom x axis), and i cant find a way to do this.

My code:

% to read the stars data:
filename = 'Hipparcos_stars2.xlsx';
sheet1 = 1;

xHRcolor = 'G2:G19934';
yHRmag = 'I2:I19934';
xHRtemp = 'J2:J19934';
yHRlum = 'K2:K19934';
HRx_c = xlsread(filename, sheet1, xHRcolor);
HRy_m = xlsread(filename, sheet1, yHRmag);
HRx_t = 10.^(3.939654 -0.395361.*HRx_c+0.2082113.*HRx_c.^2-0.0604097.*HRx_c.^3+0.007367*4.3-0.01069.*HRx_c.*4.3);
HRy_l = xlsread(filename, sheet1, yHRlum);

figure(1)
ax1 = gca;
line(HRx_c,HRy_m, 'LineStyle', 'o', 'Color', 'k', 'MarkerSize', 1);
set(ax1,'ydir','reverse');

ax2 = axes('Position',get(ax1,'Position'),...
           'XAxisLocation','top',...
           'YAxisLocation','right');
line(HRx_t,log10(HRy_l),'LineStyle', 'o','Color','k','MarkerSize', 1,'Parent',ax2);
set(ax2,'xdir','reverse');

xlabel(ax1,'B-V color')
ylabel(ax1,'V Magnitude')
xlabel(ax2,'Temperature [ºK]')
ylabel(ax2,'Luminosity [log(L/Ls)]')


This way matlab plots wrong values of the temperature in relation with the color, it plots a linear relation.
Any ideia of how can i do something like the pic in wikipedia?

Thanks in advance :)

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