本文整理匯總了Python中plotly.graph_objs.Margin方法的典型用法代碼示例。如果您正苦於以下問題:Python graph_objs.Margin方法的具體用法?Python graph_objs.Margin怎麽用?Python graph_objs.Margin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類plotly.graph_objs
的用法示例。
在下文中一共展示了graph_objs.Margin方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: plot_bar
# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Margin [as 別名]
def plot_bar(data):
app.layout = html.Div(children=[html.H1(children='CM PT'), html.Div(children='''History.'''),
dcc.Graph(
figure=go.Figure(
data = data,
layout=go.Layout(title='Streams', showlegend=False, barmode='stack', margin=go.Margin(l=200, r=0, t=40, b=20))),
style={'height': 300},
id='my-graph')
])
示例2: open_figure
# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Margin [as 別名]
def open_figure(self, fig, props):
"""Creates a new figure by beginning to fill out layout dict.
The 'autosize' key is set to false so that the figure will mirror
sizes set by mpl. The 'hovermode' key controls what shows up when you
mouse around a figure in plotly, it's set to show the 'closest' point.
Positional agurments:
fig -- a matplotlib.figure.Figure object.
props.keys(): [
'figwidth',
'figheight',
'dpi'
]
"""
self.msg += "Opening figure\n"
self.mpl_fig = fig
self.plotly_fig['layout'] = go.Layout(
width=int(props['figwidth'] * props['dpi']),
height=int(props['figheight'] * props['dpi']),
autosize=False,
hovermode='closest')
self.mpl_x_bounds, self.mpl_y_bounds = mpltools.get_axes_bounds(fig)
margin = go.Margin(
l=int(self.mpl_x_bounds[0] * self.plotly_fig['layout']['width']),
r=int(
(1-self.mpl_x_bounds[1]) * self.plotly_fig['layout']['width']),
t=int((1-self.mpl_y_bounds[1]) * self.plotly_fig['layout'][
'height']),
b=int(self.mpl_y_bounds[0] * self.plotly_fig['layout']['height']),
pad=0)
self.plotly_fig['layout']['margin'] = margin
示例3: _update_graph
# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Margin [as 別名]
def _update_graph(map_style, region):
dff = dataframe
radius_multiplier = {'inner': 1.5, 'outer': 3}
layout = go.Layout(
title=metadata['title'],
autosize=True,
hovermode='closest',
height=750,
font=dict(family=theme['font-family']),
margin=go.Margin(l=0, r=0, t=45, b=10),
mapbox=dict(
accesstoken=mapbox_access_token,
bearing=0,
center=dict(
lat=regions[region]['lat'],
lon=regions[region]['lon'],
),
pitch=0,
zoom=regions[region]['zoom'],
style=map_style,
),
)
data = go.Data([
# outer circles represent magnitude
go.Scattermapbox(
lat=dff['Latitude'],
lon=dff['Longitude'],
mode='markers',
marker=go.Marker(
size=dff['Magnitude'] * radius_multiplier['outer'],
colorscale=colorscale_magnitude,
color=dff['Magnitude'],
opacity=1,
),
text=dff['Text'],
# hoverinfo='text',
showlegend=False,
),
# inner circles represent depth
go.Scattermapbox(
lat=dff['Latitude'],
lon=dff['Longitude'],
mode='markers',
marker=go.Marker(
size=dff['Magnitude'] * radius_multiplier['inner'],
colorscale=colorscale_depth,
color=dff['Depth'],
opacity=1,
),
# hovering behavior is already handled by outer circles
hoverinfo='skip',
showlegend=False
),
])
figure = go.Figure(data=data, layout=layout)
return figure
示例4: _get_layout
# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Margin [as 別名]
def _get_layout(self, labels=[], zoom=1):
steps = []
for label in labels:
step = dict(method = 'animate',
args = [[label]],
label = label
)
steps.append(step)
top_padding = 0 if (self.title is None) else self.height/8
self.title_fontsize = self.height/20 if (self.title_fontsize=='auto') else self.title_fontsize
layout={'height':self.height,
'width':self.width,
'titlefont':{'color':self.title_fontcolor,
'size':self.title_fontsize},
#'paper_bgcolor':self.bg_color,
'paper_bgcolor':'white',
'plot_bgcolor':self.bg_color,
'xaxis': {'range': [-self.width*zoom/2, self.width*zoom/2],
'autorange': False,
'visible':self.axis_visible,
'autotick':False,
'dtick':10},
'yaxis': {'range': [-self.height*zoom/2, self.height*zoom/2],
'autorange': False,
'visible':self.axis_visible,
'autotick':False,
'dtick':10},
'margin':go.Margin(
l=0,
r=0,
b=0,
t=top_padding,
pad=0
),
'hovermode':'closest',
'title': self.title,
'sliders': [{'steps':steps}]
}
return layout