Issues getting dual y-axis ticks/values to line up
1 次查看(过去 30 天)
显示 更早的评论
I'm making a figure with two y-axes which are mutually a power law function of each other. What I want is for the y-axis ticks on the right to display their equivalent values from the right y-axis; that is, for each tick on the right y-axis I want a corresponding tick with its equivalent value on the left y-axis.
Here's the code that I've written for the figure. Note that I plot a third (empirically measured) variable as a dashed line across the plot:
figure(14)
title(['EDDR and T_{c} vs Temperature for ' sample_name])
[fig14,ax1,ax2] = plotyy([min(realTC) max(realTC)],[esr esr],realTC,Tc_EDDR,@line,@line);
set(ax1,'LineWidth',1.5,'Color','k','LineStyle','--')
set(ax2,'LineWidth',1,'Color','k','LineStyle','-')
set(fig14(1),'YColor','k','LineWidth',1)
set(fig14(2),'YColor','k','LineWidth',1)
xlabel('Temperature (°C)')
fig14(1).YLabel.String = 'Estimated Diffusion Domain Size (\mum)';
fig14(2).YLabel.String = 'Closure temperature (°C, \deltaT/\deltat = 10 °C/m.y.)';
fig14y2 = 50:20:250; % Tc values of ticks on left y-axis
set(fig14(2),'YLim',[min(fig14y2) max(fig14y2)],'YTick',fig14y2) % forces ticks on left y-axis
EDDRTc = polyfit(log(EDDR),log(Tc_EDDR),1); % solves for loglog EDDR v Tc curve as linear
fig14y1 = exp((log(fig14y2) - EDDRTc(2))/EDDRTc(1)); % solve for equivalent EDDR values of Tc ticks
set(fig14(1),'LineWidth',1,'YLim',[min(fig14y1) max(fig14y1)],'YTick',fig14y1) % forces ticks on right y-axis
legend('Observed equivalent spherical radius','Estimated diffusion domain radius')
I've attached a photo of the result, it's not quite what I was going for. Any ideas as to how to get this damn thing to work? Also, how do I limit the number of significant digits on the right y-axis to three?
0 个评论
采纳的回答
Eric Lin
2015-6-16
The following submissions on the MATLAB File Exchange may be of help:
plot2axes: allows you to provide a function that describes the relationship of one axes to another (ex. Celsius and Farenheit)
extendticklabel: allows you to specify the number of significant digits for tick labels
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!