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

  • Home
  • SEARCH
  • 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 7747917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:38:59+00:00 2026-06-01T10:38:59+00:00

I am using pylab in matplotlib to create a plot and save the plot

  • 0

I am using pylab in matplotlib to create a plot and save the plot to an image file. However, when I save the image using pylab.savefig( image_name ), I find that the SIZE image saved is the same as the image that is shown when I use pylab.show().

As it happens, I have a lot of data in the plot and when I am using pylab.show(), I have to maximize the window before I can see all of the plot correctly, and the xlabel tickers don’t superimpose on each other.

Is there anyway that I can programmatically ‘maximize’ the window before saving the image to file? – at the moment, I am only getting the ‘default’ window size image, which results in the x axis labels being superimposed on one another.

  • 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-01T10:39:01+00:00Added an answer on June 1, 2026 at 10:39 am

    You set the size on initialization:

    fig2 = matplotlib.pyplot.figure(figsize=(8.0, 5.0)) # in inches!
    

    Edit:

    If the problem is with x-axis ticks – You can set them “manually”:

    fig2.add_subplot(111).set_xticks(arange(1,3,0.5)) # You can actually compute the interval You need - and substitute here
    

    And so on with other aspects of Your plot. You can configure it all. Here’s an example:

    from numpy import arange
    import matplotlib
    # import matplotlib as mpl
    import matplotlib.pyplot
    # import matplotlib.pyplot as plt
    
    x1 = [1,2,3]
    y1 = [4,5,6]
    x2 = [1,2,3]
    y2 = [5,5,5]
    
    # initialization
    fig2 = matplotlib.pyplot.figure(figsize=(8.0, 5.0)) # The size of the figure is specified as (width, height) in inches
    
    # lines:
    l1 = fig2.add_subplot(111).plot(x1,y1, label=r"Text $formula$", "r-", lw=2)
    l2 = fig2.add_subplot(111).plot(x2,y2, label=r"$legend2$" ,"g--", lw=3)
    fig2.add_subplot(111).legend((l1,l2), loc=0)
    
    # axes:
    fig2.add_subplot(111).grid(True)
    fig2.add_subplot(111).set_xticks(arange(1,3,0.5))
    fig2.add_subplot(111).axis(xmin=3, xmax=6) # there're also ymin, ymax
    fig2.add_subplot(111).axis([0,4,3,6]) # all!
    fig2.add_subplot(111).set_xlim([0,4])
    fig2.add_subplot(111).set_ylim([3,6])
    
    # labels:
    fig2.add_subplot(111).set_xlabel(r"x $2^2$", fontsize=15, color = "r")
    fig2.add_subplot(111).set_ylabel(r"y $2^2$")
    fig2.add_subplot(111).set_title(r"title $6^4$")
    fig2.add_subplot(111).text(2, 5.5, r"an equation: $E=mc^2$", fontsize=15, color = "y")
    fig2.add_subplot(111).text(3, 2, unicode('f\374r', 'latin-1'))
    
    # saving:
    fig2.savefig("fig2.png")
    

    So – what exactly do You want to be configured?

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

Sidebar

Related Questions

I created a 3D plot using matplotlib as this: fig = pylab.figure() ax =
Using matplotlib/pylab.... How do I plot 5 heatmaps as subplots which have the same
Using a script how do I create a text file that contains all of
using (var file_stream = File.Create(users.xml)) { var serializer = new XmlSerializer(typeof(PasswordManager)); serializer.Serialize(file_stream, this); file_stream.Close();
I am using matplotlib to plot a graph with the points ([0,0,0],[0,0,1],[0,0,2],...[255,255,255]) on x-axis
I need to plot a stem plot of my signal using python and matplotlib.
I want to plot a confusion matrix using Pylab. The class labels along the
I want to make a daily profile plot: hour vs concentrations. I'm using matplotlib
Using Entity Framework CodeFirst, how do I create a created datetime column that gets
I'm trying to plot a graph in matplotlib using numpy and meshgrid. I want

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.