Python Forum
.pyplot has not attribute zlim
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
.pyplot has not attribute zlim
#1
Hey guys,

can someone explain to me this error?

"AttributeError: module 'matplotlib.pyplot' has no attribute 'zlim'"

I try to read in coordinates from a txt file. In each row, the coordinates are separated by a single tabulator.

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import csv

fig=plt.figure()
ax=fig.add_subplot(111, projection='3d')
x=[]
y=[]
z=[]
with open('fcc_coordinates_a=1.500000_5rows_5columns_5layers.dat') as csv_file:
    plots = csv.reader(csv_file, delimiter="\t")
    for row in plots:
        x.append(float(row[0]))
        y.append(float(row[1]))
        z.append(float(row[2]))
        
ax.scatter(x,y,z,c='r',marker='o')
ax.set_xlabel('x axis')
ax.set_ylabel('y axis')
ax.set_zlabel('z axis')

plt.show()

plt.xlim(0,7.5)
plt.ylim(0,7.5)
plt.zlim(0,7.5) 
Regards
Reply
#2
please, post the full traceback in error tags
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
If I run it, I get a plot as a result, but the zlim did not work and it gives:
Error:
"runfile('C:/Users/Rene/Desktop/Computational Physics/Project/Program/phase_diagram_N_hard_spheres/3D_plot.py', wdir='C:/Users/Rene/Desktop/Computational Physics/Project/Program/phase_diagram_N_hard_spheres') Traceback (most recent call last): File "<ipython-input-2-5750a66114d4>", line 1, in <module> runfile('C:/Users/Rene/Desktop/Computational Physics/Project/Program/phase_diagram_N_hard_spheres/3D_plot.py', wdir='C:/Users/Rene/Desktop/Computational Physics/Project/Program/phase_diagram_N_hard_spheres') File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 678, in runfile execfile(filename, namespace) File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 106, in execfile exec(compile(f.read(), filename, 'exec'), namespace) File "C:/Users/Rene/Desktop/Computational Physics/Project/Program/phase_diagram_N_hard_spheres/3D_plot.py", line 26, in <module> plt.zlim(0,7.5) AttributeError: module 'matplotlib.pyplot' has no attribute 'zlim'"
I am using Spyder.
Reply
#4
No one having an idea =( ?
Does that mean there might be something wrong with Spyder/Python installation?
Reply
#5
Just a shot in the dark ... maybe try plt.set_zlim(0,7.5)?
https://matplotlib.org/examples/mplot3d/...demo3.html
Reply
#6
Thank you. plt.set_zlim(x.y) doesn't work any better, but from your link it looks like using
ax.set_zlim(x,y) is the right way to go. And this gets rid of the error.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is Matplotlib.pyplot Loaded DaveG 2 1,307 Apr-06-2022, 06:12 AM
Last Post: DaveG
  Python 3.10 not happy with Pandas and PyPlot? Danno 1 1,568 Feb-26-2022, 05:35 AM
Last Post: Danno
  matplotlib.pyplot.show Alienspecimen 2 2,232 Feb-27-2021, 02:32 AM
Last Post: snippsat
  Pyplot graph size TammyP 1 1,756 Jan-26-2021, 02:15 PM
Last Post: TammyP
  Understanding The Arguments for matplotlib.pyplot.plot JoeDainton123 0 1,922 Aug-19-2020, 01:19 AM
Last Post: JoeDainton123
  Pyplot and circle Reldaing 0 1,469 Apr-01-2020, 10:44 AM
Last Post: Reldaing
  Plot a graph using matplotlib.pyplot Tibas 1 3,456 Feb-23-2018, 10:47 AM
Last Post: Tibas

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020