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 6124105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:05:41+00:00 2026-05-23T16:05:41+00:00

with help of the community in this thread: Minor grid with solid lines &

  • 0

with help of the community in this thread: Minor grid with solid lines & grey-color

I got it to work to set minor grid lines as solid and coloured style. But when adding a second y-axes it just messes up the y-ticks on the right axis! heres the example code:

x = linspace(0, 10, 11);
y1 = x.^3+1;
y2 = x+1;
y3 = y1./y2+5;

% plotte: http://www.mathworks.com/help/techdoc/ref/linespec.html
myfig = figure('Position', [500 500 445 356]); %[left, bottom, width, height]:
ax1 = axes('Position',[0.13 0.18 0.75 0.75]);
hold on

p1 = plot(x,y1,'x--r');
p2 = plot(x,y2,'*-b');

xlim([0 max(x)]);
ylim([0 max([max(y1) max(y2)])]);


col=.85*[1 1 1];
%# create a second transparent axis, same position/extents, same ticks and labels
ax2 = axes('Position',get(ax1,'Position'), ...
    'Color','none', 'Box','on', ...
    'XTickLabel',get(ax1,'XTickLabel'), 'YTickLabel',get(ax1,'YTickLabel'), ...
    'XTick',get(ax1,'XTick'), 'YTick',get(ax1,'YTick'), ...
    'XLim',get(ax1,'XLim'), 'YLim',get(ax1,'YLim'));

%# show grid-lines of first axis, give them desired color, but hide text labels
set(ax1, 'XColor',col, 'YColor',col, ...
    'XMinorGrid','on', 'YMinorGrid','on', ...
    'MinorGridLineStyle','-', ...
    'XTickLabel',[], 'YTickLabel',[]);


%# link the two axes to share the same limits on pan/zoom
linkaxes([ax1 ax2],'xy');

ax3 = axes('Position',get(ax1,'Position'),...
       'XAxisLocation','top',...
       'YAxisLocation','right',...
       'Color','none',...
       'XTickLabel', [],...
       'XColor','k','YColor','k');

%# link the two axes to share the same limits on pan/zoom
linkaxes([ax1 ax2 ax3], 'x');

ylabel(ax3, 'Speedup []');
ylim(ax3, [0 max(y3)]);

hold on
p3 = plot(x,y3,'s-.m','Parent',ax3);
hleg = legend([p1 p2 p3], {'CPU', 'GPU', 'Speedup'}, 'Location', 'NorthWest');
xlabel(ax2, 'N_{Funcs}');
ylabel(ax2, 't [s]'); 

set(hleg, 'FontAngle', 'italic')

and how it looks like:

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-23T16:05:41+00:00Added an answer on May 23, 2026 at 4:05 pm

    Its simpler than you think: when you create the second axis ax2, set the 'Box' property to 'off' instead of 'on'.

    Even more, you can simplify that part and create it as:

    ax2 = copyobj(ax1,myfig);
    delete( get(ax2,'Children') )
    set(ax2, 'Color','none', 'Box','off')
    

    enter image description here

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

Sidebar

Related Questions

With the help of this community, I've been able to pass a static chunk
With the help of this community, I just recently solved some issues with PHPExcel
With the help of the Stack Overflow community I've written a pretty basic-but fun
I've volunteered with a Non-Governmental Organization to help with their record-keeping at their community
I have implicitly made this a community wiki seeing that the answers can be
I've been full of questions lately, but thanks to this awesome community, I'm learning
am very new to this community 192.168.10.159:35621 communicates with 192.168.10.40:9000 where i have act
In this thread some one commented that the following code should only be used
Since there is a large pool of passionate developers in this community, I would
i originally followed these steps to get a RoR environmentgoing: https://help.ubuntu.com/community/RubyOnRails that worked. then

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.