Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
plt.ylabel('Population count (B)')
plt.show()
###############################################################################
# ## Stacked bar plot with plotly
###############################################################################
# Stacked area plots (with cumulated values computed depending on
# selected legends) are
# [on their way](https://github.com/plotly/plotly.js/pull/2960) at Plotly. For
# now we just do a stacked bar plot.
import plotly.offline as offline
import plotly.graph_objs as go
offline.init_notebook_mode()
""
bars = [go.Bar(x=population.index, y=population[zone], name=zone)
for zone in zones]
fig = go.Figure(data=bars,
layout=go.Layout(title='World population',
barmode='stack'))
offline.iplot(fig)
def set_export_mode(_exp_mode=True):
""" Calling this function will set export mode to true. It is necessary
to do so if we use nbconvert to export a notebook containing interactive
plotly graphics to HTML. In other words, this function should not be called
in normal usage from within Jupyter but only when we export to HTML. It is
then called once in the beginning of the notebook."""
global EXPORT_MODE
EXPORT_MODE=_exp_mode
if EXPORT_MODE:
py.init_notebook_mode(connected=False)
)
)
data = [trace1]
layout = go.Layout(
margin=dict(
l=0,
r=0,
b=0,
t=0
),
scene=dict(
aspectmode="data"
)
)
offline.init_notebook_mode(connected=True)
fig = go.Figure(data=data, layout=layout)
offline.iplot(fig)
else:
print("This function can only be used within a Jupyter notebook.")
return(False)
except NameError:
return(False)
)
)
sankey_layout = dict(
title=title,
width=width,
height=height,
font=dict(
family=font,
size=font_size
)
)
fig = dict(data=[sankey_data], layout=sankey_layout)
if not suppress_plot:
import plotly.offline
plotly.offline.init_notebook_mode()
plotly.offline.iplot(fig, validate=False)
return fig
rows=5, cols=2,
shared_xaxes=True,
vertical_spacing=0.001)
fig['layout'].update(height=1500)
self.append_trace(fig, self.positions_df, 2, 1)
self.append_trace(fig, self.balance_df, 3, 1)
self.append_trace(fig, self.holding_pnl_df, 4, 1)
self.append_trace(fig, self.commission_df, 5, 1)
self.append_trace(fig, self.margin_df, 1, 1)
self.append_trace(fig, returns_df, 2, 2, 'bar')
# fig['layout']['showlegend'] = True
if notebook:
plotly.offline.init_notebook_mode()
py.iplot(fig, filename='OnePy_plot.html', validate=False)
else:
py.plot(fig, filename='OnePy_plot.html', validate=False)
def render(df, encoding, output):
with output:
init_notebook_mode()
GraphRenderer._get_graph(encoding.chart_type).render(df, encoding, output)
surface_base:
radius corresponding to lowest height on the map
sufrace_height:
radius difference between the lowest and highest point on the map
'''
try:
from plotly.offline import plot
import plotly.graph_objs as go
import plotly
except ImportError:
import warnings
warnings.warn('The plotly package is required to use this function')
return
plotly.offline.init_notebook_mode()
traces = []
if dirty_img is not None and azimuth_grid is not None and colatitude_grid is not None:
surfacecolor = np.abs(dirty_img) # for plotting purposes
base = surface_base
surf_diff = surfacecolor.max() - surfacecolor.min()
if surf_diff > 0:
height = surface_height / surf_diff
else:
height = 0
)
if title is not None:
fig.layout.update(title=title)
filename = f'{title}.html'
else:
try:
filename = f'{fig.layout.title}.html'
except TypeError:
filename = f'{current_time()}.html'
# if colorize:
# data[0].autocolorscale = False
# data[0].surfacecolor = [0, 0.5, 1]
if env_info() == 'jupyter_notebook':
plotly_off.init_notebook_mode()
plotly_off.iplot(fig)
else:
plotly_off.plot(fig, filename=filename)
return fig
def ishow(figs, nb=True, **kwargs):
""" Show multiple plotly figures in notebook or on web. """
if isinstance(figs, (list, tuple)):
fig_main = figs[0]
for fig in figs[1:]:
fig_main['data'] += fig['data']
else:
fig_main = figs
if nb:
from plotly.offline import init_notebook_mode
from plotly.offline import iplot as plot
init_notebook_mode()
else:
from plotly.plotly import plot
plot(fig_main, **kwargs)