Axis label getting cutoff in plot with multiple axis
Show older comments
I am trying to display a label to each axis, the only problem is the top x axis, the label is getting cutoff. If I put the image in full screen I am able to see it but I need to see it without manually modifying the size of the window and keping the text size the same.
This is my code:
clear; clc; clf; close all
x1 = [1 2 3 4 5];
x2 = [2 4 8 10 12];
y1 = [3 5 7 9 10];
y2 = [4 6 9 12 15];
figure
semilogy(x1, y1, 'ko-')
hold on
semilogy(x2, y2, 'bo-')
ax1 = gca;
ax1_pos = ax1.Position;
ax1.FontSize = 14;
ylabel('y1 label')
ax2 = axes('Position',ax1_pos,'XAxisLocation','top','YAxisLocation','right','Color','none') ;
ax2.FontSize = 14;
ax2.XLim = ax1.XLim ;
ax2.YLim = ax1.YLim ;
xlabel(ax1, 'x1 label')
xlabel(ax2, 'x2 label')
ylabel('y2 label')
I was wondering if somebody could catch something that I am missing or doing wrong.
Accepted Answer
More Answers (0)
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
