Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7512883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:00:29+00:00 2026-05-30T00:00:29+00:00

The following code shows my problem. plotyy completely fails if the ticks are not

  • 0

The following code shows my problem. plotyy completely fails if the ticks are not at the same positions on both sides (which is rather the normal case…)

I require a plot with two y axis but the ticks only on one side. I was suggested to use addaxis, but I do not see how that helps me, since I do not want separated axis.

clf;
clc;
xaxis = 0:0.1:25;
ydata1 = linspace(12.1712,12.7679, length(xaxis));
ydata2 = linspace(0.3597,-28.7745, length(xaxis));

[AX,H1,H2] = plotyy(xaxis, ydata1, xaxis, ydata2);

% axis limits - x axis (min to max)
xlimits(1) = min(xaxis); xlimits(2) = max(xaxis);
set(AX, 'XLim', xlimits);
set(AX(2),'XTick',[]);

% y1 axis limits 
ylimits(1) = min(ydata1); ylimits(2) = max(ydata1);
ylimits(2) = ylimits(2) + (ylimits(2)-ylimits(1))*0.05;
set(AX(1), 'YLim', ylimits);

% y2 axis limits 
ylimits(1) = min(ydata2); ylimits(2) = max(ydata2);
ylimits(2) = ylimits(2) + (ylimits(2)-ylimits(1))*0.05;
set(AX(2), 'YLim', ylimits);

% y1 ticks 
set(AX(1),'YTick',[12.0:0.1:12.8]);
% y2 ticks 
set(AX(2),'YTick',[-25:5:0]);

print(gcf, ['-r' num2str(400)], ['test' '.png' ], ['-d' 'png']);

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T00:00:30+00:00Added an answer on May 30, 2026 at 12:00 am

    Here is an approach that I got from the mathworks forum. The idea is to remove the box property, which creates the tics on the opposite side.

    set(AX(1),'Box','off') % Turn off box of axis 1, which removes its right-hand ticks
    set(AX(2),'Box','off') % Turn off box of axis 2, which removes its left-hand ticks
    

    The downside is, that the upper line disappears. If someone knows how to get it back that would be great. Mybe with an empty plot over the current plot with the same dimensions??

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following code which shows compile time error : #include <stdio.h> int main(int
another beginner problem. Why isn't the following code with an asp.net page not working?
I have quite an embarrassing problem. The following code simply will not create a
I have a problem with the following example code that shows inconsistent behavior for
The following code shows a button that allows you to select a file (should
I have the following code that shows either a bug or a misunderstanding on
The following piece of code shows an Insert table dialog: Dialog d = WordApp.Dialogs[WdWordDialog.wdDialogTableInsertTable];
In the following code, the first log statement shows a decimal as expected, but
I am using the following code in my project. The print dialog shows, but
Spoiler alert: this is related to Problem 14 from Project Euler. The following code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.