Anzeige drehbare 3D-Diagramme in iPython oder iPython Notebook

(Mac OSX 10.10.5)

Kann ich reproduzieren, aus der matplotlib website http://matplotlib.org/gallery.html#mplot3d der Beispiel-code für ein 3D-Streudiagramm http://matplotlib.org/examples/mplot3d/scatter3d_demo.htmlaber die Handlung macht als ein statisches Bild. Ich kann nicht klicken Sie auf das Diagramm und dynamisch drehen, um die Ansicht der 3D-Daten geplottet.

Habe ich erreicht das statische 3D-Zeichnung mit Hilfe der Beispiel - code- mit (a) ipython aus im Terminal, (b) ipython notebook aus im terminal, und (c) ipython notebook aus gestartet Anaconda launcher.

Ich glaube, ich bin fehlen einige grundlegende Schritt, als Kenntnisse vorausgesetzt.

In der Vergangenheit lernen, das zeichnen hat eine GUI Python-App, die hat ein graph viewer. (Lösung 2 im code unten dargestellt öffnet diese.) Vielleicht hätte ich wissen müssen den code zum exportieren der output-Diagramm auf, dass die display-Methode? (Ja, verwenden Sie %matplotlib (nur) als erste Zeile ohne inline-oder notebook, wie gezeigt, in den Kommentaren im code-block weiter unten.)

Als ein Beispiel in ipython notebook:

    # These lines are comments
    # Initial setup from an online python notebook tutorial is below. 
    # Note the first line "%matplotlib inline" this is how the tutorial has it.
    # Two solutions 1. use: "%matplotlib notebook" graphs appear dynamic in the notebook.
    #               2. use: "%matplotlib" (only) graphs appear dynamic in separate window. 
    #    ( 2. is the best solution for detailed graphs/plots. )

    %matplotlib inline  
    import pandas as pd
    import numpy as np
    import matplotlib as mpl
    import matplotlib.pyplot as plt
    from mpl_toolkits.mplot3d import Axes3D

    pd.set_option('html',False)
    pd.set_option('max_columns',30)
    pd.set_option('max_rows',10)


    # What follows is a copy of the 3D plot example code.
    # Data is randomly generated so there is no external data import.

    def randrange(n, vmin, vmax):
        return (vmax-vmin)*np.random.rand(n) + vmin

    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    n = 100
    for c, m, zl, zh in [('r', 'o', -60, -25), ('b', '^', -30, -5)]:
        xs = randrange(n, 23, 50)
        ys = randrange(n, 0, 100)
        zs = randrange(n, zl, zh)
        ax.scatter(xs, ys, zs, c=c, marker=m)

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

    plt.show()

Kann jemand erkennen, was ich bin fehlt?

Blick auf Python 3.3.6 Dokumentation, Abschnitt 25.1 vielleicht die tkinter-Paket ...

Den tkinter-Paket ("Tk-Schnittstelle") ist das standard-Python-Schnittstelle zu Tk-GUI-toolkit. Beide Tk und tkinter sind verfügbar auf den meisten Unix-Plattformen als auch auf Windows-Systemen.

Ich denke aber, dies bezieht sich auf die Entwicklung von GUI-Programme, so bin ich nicht sicher, ob dies relevant ist. (Richtig, das war nicht nötig für die Lösung.)

InformationsquelleAutor der Frage Cam_Aust | 2015-10-30

Schreibe einen Kommentar