Clear Filters
Clear Filters

how to modify the axes scale when we plot values in both y axis with same x axis line.

1 view (last 30 days)
x1=xlsread('ERROR.xlsx') y1=xlsread('ROUND.xlsx') plot(x1); xlabel('data ratio'); ylabel('Percentage Error'); yyaxis right;
plot(y1); ylabel('Energy');
ERROR DATA 53.7578 31.3263 6.5007 2.3187 1.0973 0.9278 0.9654 0.7224 0.6327 0.549 0.4588 0.3607 0.3277 0.235 0.0671 0.1379 5.45E-02 7.50E-04 9.65E-07
ROUND DATA 282 299 305 324 341 360 378 394 413 481 496 550 569 728 794 804 1000 1000 1000 OUTPUT
how do i change in x axes,yaxes,yaxes right.In this particular example above I want to change the limit of x axes 0 to 1 with difference .1,y axxes 0 to 100 with difference 10,yaxes right 1000 to 100 with difference -50.
  5 Comments
Aquatris
Aquatris on 8 Jun 2018
For that you need to specify the xData as well. Since you are plotting like "plot(y1)", x-axis represent the data number (data #1, data #2). This is the reason why the first data point is at x = 1, second one is x = 2 and so on.
If you have the xData, you need to plot using "plot(xData,y1)". So that when you set the x-axis to be between 0 and 1, there will be data there assuming xData is between 0 and 1.
To change the x-axis range, make this change in the code;
set(gca,'xLim',[0 1])
set(gca,'xTick',0:.1:1)

Sign in to comment.

Answers (1)

Mandeep  Singh
Mandeep Singh on 8 Jun 2018
From my understanding of the question, you want to change the number of ticks and their corresponding labels in the plot. To achieve that, please follow the below steps which considers a random data set for plotting.
y = [282 299 305 324 341 360 378 394 413 481 496 550 569 728 794 804 1000 1000 1000]
plot(y)
xticks([0:2:20])
xticklabels([0:0.1:1])
Follow the same steps for changing the labels for both the y axes.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!