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 set of data with 4 types of information

Subject: one set of data with 4 types of information

From: Iris

Date: 29 Apr, 2013 13:40:10

Message: 1 of 2

Hello!
I need to do a HR Diagram like this one:
http://en.wikipedia.org/wiki/File:HRDiagram.png

Where each point have not just x and y but x1, y1, x2 and y2 (to each point i have 4 types of information).
I want to put all the points in one graph where it shows the 4 types of information in 4 axes, like in the example from wikipedia.

My code:
    
    filename = 'Hipparcos_stars2.xlsx';
    sheet1 = 1;

    xHRcolor = 'G2:G19920';
    yHRmag = 'I2:I19920';
    xHRtemp = 'J2:J19920';
    yHRlum = 'K2:K19920';
    HRx_c = xlsread(filename, sheet1, xHRcolor); % x1
    HRy_m = xlsread(filename, sheet1, yHRmag); % y1
    HRx_t = xlsread(filename, sheet1, xHRtemp); % x2
    HRy_l = xlsread(filename, sheet1, yHRlum); % y2

    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)]')

Like this it plots two sets of data, one in respect to one axes and other in respect to the second axes, which is not correct.
Any ideia of how can i do this?
Thanks in advance

Subject: one set of data with 4 types of information

From: dpb

Date: 29 Apr, 2013 21:16:58

Message: 2 of 2

On 4/29/2013 8:40 AM, Iris wrote:
> Hello!
> I need to do a HR Diagram like this one:
> http://en.wikipedia.org/wiki/File:HRDiagram.png
>
> Where each point have not just x and y but x1, y1, x2 and y2 (to each
> point i have 4 types of information).
> I want to put all the points in one graph where it shows the 4 types of
> information in 4 axes, like in the example from wikipedia.
...

> 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');
>
...

> Like this it plots two sets of data, one in respect to one axes and
> other in respect to the second axes, which is not correct.
> Any ideia of how can i do this?

PLOTYY will give you two y-axes associated w/ an overlapping pair of
x-axes at the bottom. You can make the left of these semilog by either
setting directly or using the handle form of the call.

As you have done, you can create the other x-axis at the top manually as
long as you know the scaling...I'm not up enough on the details altho
I've looked at these before just out of curiosity mostly to know what
the upper axis scaling actually is, so can't say specifically about
that. The labeling above you'll have to do w/ text() at whatever
determines those positions relative to the axis as they aren't
equivalent to the tic marks.

It's basically a case of keep on adding components until you get
something to represent each piece...

--

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