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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:42:22+00:00 2026-06-09T16:42:22+00:00

i have the following code, ripped from the Gallery import numpy as np import

  • 0

i have the following code, ripped from the Gallery

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import NullFormatter
from itertools import groupby
import matplotlib.pyplot as plt
import numpy
#fig = plt.figure(figsize=(13, 12))

files = ("file1","file2")
place = (1,2)
print files
print place
plt.bone()
for f in zip(files,place):
    print "file", f
    # would like the two below each other, don't know how, so i clear
    plt.clf()
    # data comes from the files normally
    x = np.random.randn(1000)
    y = np.random.randn(1000)
    z = np.random.randn(100)

    nullfmt   = NullFormatter()         # no labels

    # definitions for the axes
    left, width = 0.1, 0.65
    bottom, height = 0.1, 0.65
    bottom_h = left_h = left+width+0.02

    rect_scatter = [left, bottom, width, height]
    rect_histx = [left, bottom_h, width, 0.2]
    rect_histy = [left_h, bottom, 0.2, height]

    # start with a rectangular Figure
    plt.figure(1, figsize=(8,8))
    plt.xlabel('$^{13}$C (ppm)')
    plt.ylabel('$^{15}$H (ppm)')


    axScatter = plt.axes(rect_scatter)
    axHistx = plt.axes(rect_histx)
    axHisty = plt.axes(rect_histy)

    # no labelsfor the histgrams
    axHistx.xaxis.set_major_formatter(nullfmt)
    axHisty.yaxis.set_major_formatter(nullfmt)

    # the scatter plot:
    #axScatter.scatter(x, y)
    axScatter.scatter(numpy.float64(x),numpy.float64(y), c=numpy.float64(z),lw=0.1,s=5)

    # now determine nice limits by hand:
    binwidth = 0.25
    xymax = np.max( [np.max(np.fabs(x)), np.max(np.fabs(y))] )
    lim = ( int(xymax/binwidth) + 1) * binwidth

    axScatter.set_xlim( (min(x), max(x)+binwidth) )
    axScatter.set_ylim( (min(y), max(y)+binwidth) )
    #axScatter.set_ylim( (-lim, lim) )
    binwidth = (max(x) - min(x))/20
    bins = np.arange(min(x), max(x) + binwidth, binwidth)
    axHistx.hist(x, bins=bins)
    binwidth = (max(y) - min(y))/20
    bins = np.arange(min(y), max(y) + binwidth, binwidth)
    axHisty.hist(y, bins=bins, orientation='horizontal')

    axHistx.set_xlim( axScatter.get_xlim() )
    axHisty.set_ylim( axScatter.get_ylim() )
    plt.savefig(f[0]+"out_hist.png", format='png',dpi=1200)
    plt.savefig(f[0]+"out_hist.svg", format='svg')  

This code gives me:
example

However, i don’t know where this frame in the background is coming from. And also i would like to have my captions centered on the plot, not the whole thing. Lastly i could not for the life of me get these plots below each other in a simple JPG. How do i solve these problems?

  • 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-09T16:42:24+00:00Added an answer on June 9, 2026 at 4:42 pm

    When you call plt.xlabel(), pyplot will create an axes, that’s the background axes. delete the two lines call plt.xlabel() & plt.ylabel() and add following lines after axScatter = plt.axes(rect_scatter)

    axScatter.set_xlabel('$^{13}$C (ppm)')
    axScatter.set_ylabel('$^{15}$H (ppm)')    
    

    enter image description here

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

Sidebar

Related Questions

I have following code import sys from ctypes import * from ctypes.util import find_library
I have following code for loading image from url in xml parsing endElement method
I have following code in Java: import java.util.*; public class longest{ public static void
I have following code.. $query = SELECT quote, author FROM quotes ORDER BY id
i have following code in which, i am fetching the data from the sqlite
I have following code: import java.io.*; import java.util.concurrent.* ; public class Example{ public static
I have following code in initialization im = imread('Image02.tif'); figure(); imagesc(im); colormap(gray); [hImage hfig
I have following code <div id=main> <div id=one> </div> <div id=two> </div> <div id=three>
I have following code for updating user's column public void UpdateLastModifiedDate(string username) { using
I have following code for inserting data into database using PDO. It inserts data

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.