我正在尝试做一个像这样的 Hertzsprung-Russell 图:http://en.wikipedia.org/wiki/File: HRDiagram.png 我有 4 种不同类型的数据用于同一点(我们称之为 x1,y1 , x2, y2) 并且我想将它们放在同一个图中,显示 4 个轴(其中 2 个轴像往常一样位于底部和左侧,另外 2 个位于顶部和右侧)。我的代码:
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)]')
像这样,我最终得到一个带有 4 轴的图形,但关于第二组轴的信息错误。问题是,使用此代码,它不会使第二组轴适应数据,并且对于我选择的任何点,它呈现 x2 和 y2 的正确值,但 x1 和 y1 的值错误。知道如何在维基百科中做类似的事情吗?提前致谢
对于 Hipparcos_stars2.xlsx:http ://www1.datafilehost.com/d/7d652c04