from plotly.offline import init_notebook_mode, plot, iplot
import plotly.graph_objs as go
init_notebook_mode(connected=True)
trace_test = go.Scatter(x=[1,2,3], y=[7,5,9], marker={'color': 'red', 'symbol': 104, 'size': 10},
mode="markers+lines", text=["one","two","three"], name='1st Trace')
data = [trace_test]
layout = go.Layout(title="First Plot", xaxis={'title':'x1'}, yaxis={'title':'x2'})
figure = go.Figure(data=data, layout=layout)
iplot(figure, filename='pyguide_1')
figure
Figure({ 'data': [{'marker': {'color': 'red', 'size': 10, 'symbol': 104}, 'mode': 'markers+lines', 'name': '1st Trace', 'text': [one, two, three], 'type': 'scatter', 'uid': '4b5288c3-88ae-4ae1-a6a2-a8fb2685c936', 'x': [1, 2, 3], 'y': [7, 5, 9]}], 'layout': {'title': 'First Plot', 'xaxis': {'title': 'x1'}, 'yaxis': {'title': 'x2'}} })
figure.update({'layout' : {'title': 'Plot Update'}, 'data': [{'marker': {'color': 'green', 'symbol': 103}}]})
iplot(figure, filename='pyguide_')
import pandas as pd
--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) <ipython-input-7-7dd3504c366f> in <module> ----> 1 import pandas as pd ModuleNotFoundError: No module named 'pandas'
df = pd.read_csv('world-university-rankings/timesData.csv')
time_df = df.iloc[:100,:]
time_df.head(10)
trace1 = go.Scatter(
x = time_df.world_rank,
y = time_df.citations,
mode = "lines",
name = "citations",
marker = dict(color = 'rgba(16, 112, 2, 0.8)'),
text= time_df.university_name)
trace2 = go.Scatter(
x = time_df.world_rank,
y = time_df.teaching,
mode = "lines+markers",
name = "teaching",
marker = dict(color = 'rgba(80, 26, 80, 0.8)'),
text= time_df.university_name)
data = [trace1, trace2]
layout = dict(title = 'Citation and Teaching vs World Rank of Top 100 Universities',
xaxis= dict(title= 'World Rank',ticklen= 5,zeroline= False)
)
fig = dict(data = data, layout = layout)
iplot(fig)
import cufflinks as cf
cf.go_offline()
time_df.iplot(x='world_rank', y=['citations', 'teaching'],
kind='scatter', xTitle="World Rank", text='university_name',
mode=['lines', 'lines+markers'],
filename='cufflinks/cf-simple-line')