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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:43:52+00:00 2026-05-30T02:43:52+00:00

I would like to automatically create graphs of Hardness H and Young’s modulus E

  • 0

I would like to automatically create graphs of Hardness H and Young’s modulus E of samples as function of load L of indenter.

My goal is to get opaque markers connected with dashed lines. When using set(handle,'linestyle',spec) or line(...,'linestyle',spec) command I got markers or lines, never both of them – MATLAB throws error.
Is there way to get lines and markers without plotting two lines with same data and different specs? I’d like to continue with this to work with legend as described in another question (MATLAB: legend for plotyy with multiple data sets).

Here is my actual MWE code:

%data1 - m x 3 matrix with data for first sample:
[m,n]=size(data1);

%plots 1st sample data:
[ax,h1,h2]=plotyy([data1(1:m,1)],[data1(1:m,2)],[data1(1:m,1)],[data1(1:m,3)]);

set(h1,'linestyle','o')
set(h2,'linestyle','o')

%store colors:
c1=get(h1,'color');c2=get(h2,'color');

%plots 2nd sample hardness:
line('parent',ax(1),'xdata',[data2(1:m,1)],'ydata',[data2(1:m,2)],...
     'color',c1,'linestyle','s');

%plots 2nd sample young's modulus
line('parent',ax(2),'xdata',[data2(1:m,1)],'ydata',[data2(1:m,3)],...
     'color',c2,'linestyle','s');
  • 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-30T02:43:54+00:00Added an answer on May 30, 2026 at 2:43 am

    I think you may be overcomplicating it?

    Try something like this:

    % MarkerSize determines the size of the markers
    % MarkerEdgeColor determines the color of the markers themselves
    % Color determines the line color connecting them
    data = rand(1,5);
    plot(data, '.--', 'MarkerSize', 50, 'MarkerEdgeColor', [0.1 0.8 0.2], 'Color', [0.9 0.2 .4]);
    

    It produces the following image of opaque markers connected with dashed lines:

    Plot

    To support plotyy, the process is basically the same, except you have to set some properties on both the parent and child axes. Here’s some example code:

    % Generate some data
    datax1 = rand(1,5);
    datay1 = rand(1,5);
    datax2 = rand(1,5);
    datay2 = rand(1,5);
    
    % Plot the data    
    [ax, h1, h2] = plotyy(datax1, datay1, datax2, datay2);
    
    % Different line styles for each child plot
    set(h1, 'LineStyle', '--');
    set(h2, 'LineStyle', '-.');
    
    % Different markers for each child plot
    set(h1, 'Marker', '.');
    set(h2, 'Marker', '+');
    
    % Different marker sizes for each child plot
    set(h1, 'MarkerSize', 50);
    set(h2, 'MarkerSize', 5);
    
    % Generate two colors. We keep a copy so we can set the axes to match.
    color1 = rand(1,3);
    color2 = rand(1,3);
    
    % The face colors are darker versions of the colors.
    set(h1, 'MarkerEdgeColor', color1 * 0.5);
    set(h2, 'MarkerEdgeColor', color2 * 0.5);
    
    % This is the plot line color.
    set(h1, 'Color', color1);
    set(h2, 'Color', color2);
    
    % Set the axis colors to match the plot colors.
    set(ax(1), 'YColor', color1);
    set(ax(2), 'YColor', color2);
    

    Which produces the following image:

    enter image description here

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

Sidebar

Related Questions

Using LINQ-to-SQL, I would like to automatically create child records when inserting the parent
I would like to have my .Net C# program automatically create YouTrack tickets when
I would like to create a new unix command to automatically list the contents
I would like to automatically convert between tabs and spaces for indentation when I
I would like to automatically align lines of python variable assignments in vim. For
When creating a new file with vim, I would like to automatically add some
I'm writing a forum-type discussion board in Perl and would like to change automatically
Would like to make anapplication in Java that will not automatically parse parameters used
We would like to implement a web form that automatically saves content at regular
I would like to change a program to automatically detect whether a terminal is

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.