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!