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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:55:14+00:00 2026-06-13T02:55:14+00:00

I’m plotting the same data in two different formats: log scale and linear scale.

  • 0

I’m plotting the same data in two different formats: log scale and linear scale.

Basically I want to have exactly the same plot, but with different scales, one on the top of the other.

What I have right now is this:

import matplotlib.pyplot as plt

# These are the plot 'settings'
plt.xlabel('Size')
plt.ylabel('Time(s)');
plt.title('Matrix multiplication')

plt.xticks(xl, rotation=30, size='small')
plt.grid(True)

# Settings are ignored when using two subplots

plt.subplot(211)
plt.plot(xl, serial_full, 'r--')
plt.plot(xl, acc, 'bs')
plt.plot(xl, cublas, 'g^')

plt.subplot(212)
plt.yscale('log')
plt.plot(xl, serial_full, 'r--')
plt.plot(xl, acc, 'bs')
plt.plot(xl, cublas, 'g^')

All ‘settings’ before plt.subplot are ignored.

I can get this to work the way I want, but I have to duplicate all the settings after each subplot declaration.

Is there a way to do configure both subplots at once?

  • 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-13T02:55:16+00:00Added an answer on June 13, 2026 at 2:55 am

    The plt.* settings usually apply to matplotlib’s current plot; with plt.subplot, you’re starting a new plot, hence the settings no longer apply to it. You can share labels, ticks, etc., by going through the Axes objects associated with the plots (see examples here), but IMHO this would be overkill here. Instead, I would propose putting the common “styling” into one function and call that per plot:

    def applyPlotStyle():
        plt.xlabel('Size')
        plt.ylabel('Time(s)');
        plt.title('Matrix multiplication')
    
        plt.xticks(range(100), rotation=30, size='small')
        plt.grid(True)
    
    plt.subplot(211)
    applyPlotStyle()
    plt.plot(xl, serial_full, 'r--')
    plt.plot(xl, acc, 'bs')
    plt.plot(xl, cublas, 'g^')
    
    plt.subplot(212)
    applyPlotStyle()
    plt.yscale('log')
    plt.plot(xl, serial_full, 'r--')
    plt.plot(xl, acc, 'bs')
    plt.plot(xl, cublas, 'g^')
    

    On a side note, you could root out more duplication by extracting your plot commands into such a function:

    def applyPlotStyle():
        plt.xlabel('Size')
        plt.ylabel('Time(s)');
        plt.title('Matrix multiplication')
    
        plt.xticks(range(100), rotation=30, size='small')
        plt.grid(True)
    
    def plotSeries():
        applyPlotStyle()
        plt.plot(xl, serial_full, 'r--')
        plt.plot(xl, acc, 'bs')
        plt.plot(xl, cublas, 'g^')
    
    plt.subplot(211)
    plotSeries()
    
    plt.subplot(212)
    plt.yscale('log')
    plotSeries()
    

    On another side note, it might suffice to put the title at the top of the figure (instead of over each plot), e.g., using suptitle. Similary, it might be sufficient for the xlabel to only appear beneath the second plot:

    def applyPlotStyle():
        plt.ylabel('Time(s)');
    
        plt.xticks(range(100), rotation=30, size='small')
        plt.grid(True)
    
    def plotSeries():
        applyPlotStyle()
        plt.plot(xl, serial_full, 'r--')
        plt.plot(xl, acc, 'bs')
        plt.plot(xl, cublas, 'g^')
    
    plt.suptitle('Matrix multiplication')
    plt.subplot(211)
    plotSeries()
    
    plt.subplot(212)
    plt.yscale('log')
    plt.xlabel('Size')
    plotSeries()
    
    plt.show()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I've tracked down a weird MySQL problem to the two different ways I was
I want to construct a data frame in an Rcpp function, but when I
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a jquery bug and I've been looking for hours now, I can't

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.