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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:01:10+00:00 2026-05-26T08:01:10+00:00

I know how to cycle through a list of colors in matplotlib. But is

  • 0

I know how to cycle through a list of colors in matplotlib. But is it possible to do something similar with line styles (plain, dotted, dashed, etc.)? I’d need to do that so my graphs would be easier to read when printed. Any suggestions how to do that?

  • 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-26T08:01:10+00:00Added an answer on May 26, 2026 at 8:01 am

    Something like this might do the trick:

    import matplotlib.pyplot as plt
    from itertools import cycle
    lines = ["-","--","-.",":"]
    linecycler = cycle(lines)
    plt.figure()
    for i in range(10):
        x = range(i,i+10)
        plt.plot(range(10),x,next(linecycler))
    plt.show()
    

    Result:
    enter image description here

    Edit for newer version (v2.22)

    import matplotlib.pyplot as plt
    from cycler import cycler
    #
    plt.figure()
    for i in range(5):
        x = range(i,i+5)
        linestyle_cycler = cycler('linestyle',['-','--',':','-.'])
        plt.rc('axes', prop_cycle=linestyle_cycler)
        plt.plot(range(5),x)
        plt.legend(['first','second','third','fourth','fifth'], loc='upper left', fancybox=True, shadow=True)
    plt.show()
    

    For more detailed information consult the matplotlib tutorial on “Styling with cycler”
    To see the output click “show figure“

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

Sidebar

Related Questions

I know I can cycle through my tabs using cmd+{ or cmd+}, but is
For a small project I'm working on I need to cycle through a list.
Know this might be rather basic, but I been trying to figure out how
Know if it's possible to access the iPhone compass in Safari using JavaScript? I
Anyone know if it's possible to databind the ScaleX and ScaleY of a render
I know that I can do something like $int = (int)99; //(int) has a
Im trying to build a kd-tree for searching through a set of points, but
I'm in the final stages of going round trip through the entire Rails cycle:
I would like to cycle through all the elements in a submitted form, assign
I know Octave/MATLAB can play arrays as sound, but I was wondering if Octave

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.