Plotly (https://plot.ly/) bir veri görselleştirme kütüphanesi. Birden fazla programlama diliyle veriyi iki boyutlu veya üç boyutlu görselleştirme arayüzleri sunuyor. Bulut ortamında da görselleri kaydetme imkanı sağlıyor.
Python ile yukarıdaki gibi üç boyutlu bir grafik çizmek için ilgili X, Y ve Z değerlerini vererek aşağıdaki python kodunu kullanabiliriz. Aşağıda daha önce Pandas ile oluşturulmuş bir DataFrame’den (transitDataFrame) iki farklı etikette veri alınıp görselleştirilmiş. Burada transitDataframe.label bölümü veri filtrelemeyi, head fonksiyonu ise ilk 2000 değeri getirmeyi sağlıyor. İki farklı etikette görselleştirme için iki farklı Scatter3d ‘yi veri olarak notebook‘a vermek gerekiyor.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
import plotly.plotly as py import plotly.graph_objs as go import plotly.offline as po from plotly.graph_objs import * trace1 = go.Scatter3d( x = transitDataframe[transitDataframe.label=='bus'].x.head(2000), y = transitDataframe[transitDataframe.label=='bus'].y.head(2000), z = transitDataframe[transitDataframe.label=='bus'].z.head(2000), mode = 'markers', name = 'bus', marker=dict( color='rgb(76, 153, 0)', #showscale=True, size='4', #colorscale='Spectral', opacity=0.5 ) ) trace2 = go.Scatter3d( x = transitDataframe[transitDataframe.label=='walking'].x.head(2000), y = transitDataframe[transitDataframe.label=='walking'].y.head(2000), z = transitDataframe[transitDataframe.label=='walking'].z.head(2000), mode = 'markers', name = 'walking', marker=dict( color='rgb(255, 0, 51)', #showscale=True, size='4', #colorscale='Spectral', opacity=0.5 ) ) data = [trace1, trace2] # Plot and embed in ipython notebook! po.init_notebook_mode(connected=False) po.iplot(data, filename='basic-scatter') |