omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    How to make my 3D scatter graph rotating to view

    Pythonista
    pythonista animation matplotlib
    2
    3
    13283
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Kangaroo
      Kangaroo last edited by

      This is my program:

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

      fig = plt.figure()
      ax = fig.add_subplot(111, projection='3d')

      x =[1,2,3,4,5,6,7,8,9,10]
      y =[5,6,2,3,13,4,1,2,4,8]
      z =[2,3,3,3,5,7,9,11,9,10]

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

      ax.set_xlabel('X Label')
      ax.set_ylabel('Y Label')
      ax.set_zlabel('Z Label')

      plt.show()

      I don't know why my graph is fixed in one position.It is difficult to check every point when my data become larger.
      So,I want to make my graph rotating automatically since it is easy to view every point.
      Does anyone can help me?

      1 Reply Last reply Reply Quote 0
      • abcabc
        abcabc last edited by

        This post is deleted!
        1 Reply Last reply Reply Quote 0
        • abcabc
          abcabc last edited by abcabc

          Does this help?

          from mpl_toolkits.mplot3d import Axes3D
          import matplotlib.pyplot as plt
          
          fig = plt.figure()
          ax = fig.add_subplot(111, projection='3d')
          
          x =[1,2,3,4,5,6,7,8,9,10]
          y =[5,6,2,3,13,4,1,2,4,8]
          z =[2,3,3,3,5,7,9,11,9,10]
          
          ax.scatter(x, y, z, c='r', marker='o')
          
          ax.set_xlabel('X Label')
          ax.set_ylabel('Y Label')
          ax.set_zlabel('Z Label')
          
          for i in range(0, 360, 45):
              ax.view_init(None, i)
              plt.show()
          
          

          Also see this link
          https://forum.omz-software.com/topic/1961/putting-a-matplotlib-plot-image-into-a-ui-imageview
          You can generate and save the images and then make a gif or carousel. Built-in examples contain code to generate gif and here is the code to make a image carousel.
          https://gist.github.com/balachandrana/de389c3bd84f006ad4c8d5e3d1cd4a8d

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors