Python interactive visualization Flashcards
from plotly import __version__
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
Importuojama plotly biblioteka
import cufflinks as cf
init_notebook_mode(connected=True)
cf.go_offline()
Importuojama cufflinks biblioteka
df.iplot()
Sukuriama paprasta vingiuota tiesine diagrama
df.iplot(kind=’scatter’,x=’A’,y=’B’,mode=’markers’,size=10)
Sukuriama interaktyvi scatter diagrama su nustatytais nustatymais
df2.iplot(kind=’bar’,x=’Category’,y=’Values’)
Interaktyvi stulpeline diagrama
df.iplot(kind=’box’)
Box diagrama
df3 = pd.DataFrame({‘x’:[1,2,3,4,5],’y’:[10,20,30,20,10],’z’:[5,4,3,2,1]})
df3.iplot(kind=’surface’,colorscale=’rdylbu’)
3D diagrama
df[[‘A’,’B’]].iplot(kind=’spread’)
Sukuriama tiesine diagrama ,dazniausiai naudojama stock markete
df.iplot(kind=’bubble’,x=’A’,y=’B’,size=’C’)
Sukuriama taskeline diagrama
df.scatter_matrix()
Sukuriama 4X4 matrica ,kur pagrindine istrizaines elementai yra stulpeline diagrama ,o likusieji scatter
df = pd.read_csv(‘2014_World_GDP’)
df.head()
data = dict(
type = ‘choropleth’,
locations = df[‘CODE’],
z = df[‘GDP (BILLIONS)’],
text = df[‘COUNTRY’],
colorbar = {‘title’ : ‘GDP Billions US’},
)
layout = dict(
title = ‘2014 Global GDP’,
geo = dict(
showframe = False,
projection = {‘type’:’Mercator’}
)
)
choromap = go.Figure(data = [data],layout = layout)
iplot(choromap)
Sukuriamas interaktyvaus zemelapio diagrama