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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:46:13+00:00 2026-06-11T19:46:13+00:00

I am doing my scatter plots in matplotlib and they are generating well. However,

  • 0

I am doing my scatter plots in matplotlib and they are generating well. However, to display the correlations between x and y, I need to add histograms on both axes as subplots (like shown in this example). Since the code in the example is a bit complicated, so I am not able to follow how to get my scatter plots to have these. Here is my code:

import matplotlib.pyplot as plt
import numpy
from statlib import stats
from math import log

x1=numpy.loadtxt("a.txt")
x2 = numpy.loadtxt("b.txt")


x1 = numpy.array(x1)
x2 = numpy.array(x2)
x1 = x1.reshape(82,296)
x2 = x2.reshape(82,296)
x = numpy.vstack([x1, x2])


y1=numpy.loadtxt("c.txt")
y2=numpy.loadtxt("d.txt")

y1 = numpy.array(y1)
y2 = numpy.array(y2)

y1 = y1.reshape(82,296)
y2 = y2.reshape(82,296)

y = numpy.vstack([y1, y2])


plot = plt.scatter(y,x)
plt.grid('on')
plt.xlabel('X')
plt.ylabel('Y')
plt.ylim(-20,1000)
plt.title('Scatter Plot')

plt.show()

Any help would be REALLY helpful.

  • 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-11T19:46:14+00:00Added an answer on June 11, 2026 at 7:46 pm

    Copy the code from the example.

    Locate the line

    axScatter.scatter(x, y)
    

    This creates the scatter plot. Compare it with your line

    plot = plt.scatter(y,x)
    

    They are basically the same except that the x and y are reversed. So to connect your code to the example,
    Simply replace

    x = np.random.randn(1000)
    y = np.random.randn(1000)
    

    (from the example) with your code defining y and x.

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

Sidebar

Related Questions

Doing so select name from sqlite_master where type='table' but I need to display all
Doing the below will reproduce my problem: New WPF Project Add ListView Name the
Doing a very simple loop to display various data, for _test in @test ...
doing the first Project Euler question: summing the multiples of 3 and 5 between
Doing some SOAP calls to a 3rd party application. They provide this soap header
Doing validation in my binder, I'm wondering if there's a need to check the
Doing the getting started of Sinatra. I get this error: ./sinatra.rb:5: undefined method `get'
Doing an ajax get request works as expected using the following code: $.ajax({ type:
Doing my first SL4 MVVM RIA based application and i ran into the following
Doing my first tryouts with foreign keys in a mySQL database and are trying

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.