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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:03:41+00:00 2026-06-01T20:03:41+00:00

When I plot several curves on the same plot using hold on , each

  • 0

When I plot several curves on the same plot using hold on, each curve defaults to the same color (blue). I’d like them to have all different colors.

One solution I’ve seen is to make a color vector, e.g. c = ['k', 'g', 'r', ...] and loop over it, but I don’t like this solution. Things will break if my number of plots is greater than the length of my color vector c, and I don’t want to have to define c in every file.

Is there a better solution?

  • 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-06-01T20:03:42+00:00Added an answer on June 1, 2026 at 8:03 pm

    Try using hold all instead. Your curves should cycle over the colormap automatically. From help hold:

    hold all holds the graph and the current line color and line style so
    that subsequent plotting commands do not reset the ColorOrder and
    LineStyleOrder property values to the beginning of the list. Plotting
    commands continue cycling through the predefined colors and line
    styles from where the last graph stopped in the list.

    You can examine the colormap with get(gca,'ColorOrder').

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

Sidebar

Related Questions

I'd like to plot several distinct boxplot in Matlab, but give them the same
I would like to have several subplots in a row in a plot. However
I have a simple plot with several sets of points and lines connecting each
I have several time series, which when I plot using, plot(na.omit(d)) I get the
I want to plot several curves, each having a different length. So, I've placed
I'm trying to plot several kernel density estimations on the same graph, and I
I have several plt.plot instances and I wanted to only plt.show() certain objects. To
I have several phylogenetic trees imported into R from Newick format. I am using
I'm using MATLAB to plot some data. I would like to create the legend
I'd like to plot multiple plots in separate bitmap files using the file name

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.