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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:48:09+00:00 2026-05-27T23:48:09+00:00

I am trying to make a scatter plot in Python. I supposed it will

  • 0

I am trying to make a scatter plot in Python. I supposed it will be fairly simple but got stuck with understanding in scatterplot (x and y value) while plotting.

==My mission ==

  • I have database and more then 10k record (all float) till now and will increase on daily basis.
  • The record range is from 200-2000 (in float decimal).
  • So, I want to see the most populated region in my dataset.

==What I did?==

import numpy as np
import pylab as pl
import MySQLdb
import sys
import math

conn = MySQLdb.connect(
    host="localhost",
    user="root",
    passwd="root",
    db="myproject")

with conn:
    cur = conn.cursor()

    #will fetch all recoreds called monoiso field
    cur.execute("SELECT monoiso FROM pmass_selectedion")
    rows = cur.fetchall()

    for row in rows:

        #xvalue for monoiso variable and yvalue for range 
        xvalue = row
        yvalue = [600]

        # tried this way too but got x and y dimension error
        #yvalue = [400,800,1200,1600]

        pl.plot(xvalue,yvalue,'ro')
pl.show()

Scatterplot Understanding (link)

enter image description here

Ok! this plot doesnt make any sense.

==Question ==

  • How to make scatter plot to see the most populated region?
  • How can I assign y variable to make equal dimension with x variable(total number of fetched records)?

New to plotting and statistic so please help me out

  • 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-27T23:48:09+00:00Added an answer on May 27, 2026 at 11:48 pm

    Perhaps you are looking for a matplotlib histogram:

    import numpy as np
    import MySQLdb
    import matplotlib.pyplot as plt # This is meant for scripts
    # import pylab as pl # This is meant for interactive sessions; 
    import operator
    
    conn = MySQLdb.connect(
        host="localhost",
        user="root",
        passwd="root",
        db="myproject")
    
    with conn:
        cur = conn.cursor()
    
        #will fetch all recoreds called monoiso field
        cur.execute("SELECT monoiso FROM pmass_selectedion")
        rows = cur.fetchall()
    
    monoisos = [row[0] for row in rows]
    
    # Make a histogram of `monoisos` with 50 bins.
    n, bins, histpatches = plt.hist(monoisos, 50, facecolor = 'green')
    plt.show()
    

    enter image description here


    You can also make a histogram/dot-plot by using numpy.histogram:

    momoisos = [row[0] for row in rows]
    hist, bin_edges = np.histogram(monoisos, bins = 50)
    mid = (bin_edges[1:] + bin_edges[:-1])/2
    plt.plot(mid, hist, 'o')
    plt.show()
    

    enter image description here


    Regarding the use of pylab: The docstring for pyplot says

    matplotlib.pylab combines pyplot with numpy into a single namespace.
    This is convenient for interactive work, but for programming it is
    recommended that the namespaces be kept separate.

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

Sidebar

Related Questions

I'm trying make my first python app. I want make simple email sender form.
I am trying to create a simple scatter plot with PlotSymbols for when I
trying to make a page which will recursively call a function until a limit
While trying to make one of my python applications a bit more robust in
Im trying to make a function that will return an element of type point:
im trying make one replace in string from a array but this dont work
I'm trying make a static text which if too long for the sizer, will
Trying to make a simple toggle menu, and I can't seem to hide/show the
Trying to make this simple applet - the first part just creates a simple
I am trying to make a 3D plot from x, y, z points list,

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.