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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:15:39+00:00 2026-05-16T00:15:39+00:00

I’m very new to python. two days. trying to get a plot working with

  • 0

I’m very new to python. two days. trying to get a plot working with matplotlib. I’m getting this error:

cannot perform reduce with flexible type

the line with the error is:

ax.scatter(x,y,z,marker='o')

Variables:

ax is defined as: ax = Axes3D(fig)

fig is defined as: fig = plt.figure()

x, y, z are lists

Any python experts tell me why? I got the plot to work but the values are integers. Decimal values are preferred.

I read that lists in python are not very good with numbers… can someone clarify? I got it to work with lists and ndarrays but all the values have to be integers.

Thanks!

  • 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-16T00:15:39+00:00Added an answer on May 16, 2026 at 12:15 am

    Thanks for the responses.

    I got it working with floats but maybe you all can tell me why. I just created an account here and can’t edit my guest question…

    I’m getting my data from a sqlite database. I can round the values in the sql or cast to floats and it works. I’m guessing that the data was a numerical object even though it was numerical. Is this correct?

    Here’s an excerpt of the code that doesn’t work. I got it to work by casting the values as floats.

    
    import sqlite3
    import re
    import numpy as np
    from numpy import *
    from mpl_toolkits.mplot3d import Axes3D
    import matplotlib.pyplot as plt
    
    conn = sqlite3.connect('./RES/resDB.dbl')
    
    fig = plt.figure()
    ax = Axes3D(fig)
    
    sam = array([])
    x = array([])
    y = array([])
    z = array([])
    
    for sv in conn.execute('select sam,easting,northing,altitude from trx_all'):
        sam = np.append(sam, [sv[0]]) #this works: sam = np.append(sam, [float(sv[0])])
        x = np.append(x, [sv[1]]) #this works: x = np.append(x, [float(sv[1])])
        y = np.append(y, [sv[2]]) #this works: y = np.append(y, [float(sv[2])])
        z = np.append(z, [sv[3]]) #this works: z = np.append(z, [float(sv[3])])
    if sam.__len__() > 0:
        print(repr(x))
        print(repr(y))
        print(repr(z))
        ax.scatter(x, y, z, marker='o')
    ax.set_xlabel('X')
    ax.set_ylabel('Y')
    ax.set_zlabel('Z')
    ax.set_title("3D plot")
    plt.show()
    
    

    unutbu requested the output of print(repr(x)):

    
    x: array([u'227004.744896075', u'227029.694213685', u'227051.351657645', ...,
           u'226416.484484696', u'226436.436477995', u'226401.253669657'],
          dtype='U16')
    y: array([u'3648736.75423911', u'3648737.3357031', u'3648746.34280013', ...,
           u'3645870.67565062', u'3645893.61216942', u'3645866.95833722'],
          dtype='U16')
    z: array([u'1600.2589433603', u'1535.77224937826', u'1429.01016684435', ...,
           u'341.064685015939', u'343.452275622636', u'312.491347198375'],
          dtype='U16')
    

    and finally here’s the error that it outputs on the line ax.scatter(x,y,z,marker=’o’) :

    
    Traceback (most recent call last):
      File "C:\stripped_3dplot.py", line 27, in 
        ax.scatter(x, y, z, marker='o')
      File "C:\Python27\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py", line 1019, in scatter
        patches = Axes.scatter(self, xs, ys, *args, **kwargs)
      File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 5813, in scatter
        minx = np.amin(temp_x)
      File "C:\Python27\lib\site-packages\numpy\core\fromnumeric.py", line 1846, in amin
        return amin(axis, out)
    TypeError: cannot perform reduce with flexible type
    

    Like i said i think it was just the wrong type, but if you all can tell me what type causes the error i could learn something.

    Thanks.

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

Sidebar

Ask A Question

Stats

  • Questions 464k
  • Answers 464k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You first need to create an instance of GameAEngine beofre… May 16, 2026 at 1:00 am
  • Editorial Team
    Editorial Team added an answer <div id='panel2' style='z-index:3; width:100px; height:100px; background-color:yellow'> </div> <div id='panel1' style='z-index:5;… May 16, 2026 at 1:00 am
  • Editorial Team
    Editorial Team added an answer Camera samples only run in the device ;) There is… May 16, 2026 at 1:00 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.