密谋:如何在边框上添加边框和侧面标签,以及如何同步平移? - python

下图是我尝试在Python中使用Plotly(位于最底部的代码)进行2x2绘图的情况。
密谋:如何在边框上添加边框和侧面标签,以及如何同步平移? - python

我正在尝试改善图表,但似乎无法执行以下操作:

每个子图上的边框
在所有绘图上同步平移和缩放。尽管我正在使用shared_xaxes和shared_yaxes,但它仅适用于子图的行和列。因此,如果我在左下图上平移,则右上图将保持不变。
侧面标签来标记子图。请参阅,例如密谋:如何在边框上添加边框和侧面标签,以及如何同步平移? - python

任何帮助将非常感激。以下是到目前为止的代码。

import plotly.offline as poff
import plotly.tools as tls

x = list(range(10,20))
y = x
y1 = [10-i for i in x]
y2 = [abs(i-5) for i in x]
y3 = [abs(2*i- 5) for i in x]

fig = tls.make_subplots(rows=2, cols=2, shared_xaxes=True, shared_yaxes=True,
                        vertical_spacing=0.01,
                        horizontal_spacing=0.01, print_grid=True)
fig.append_trace(go.Scatter({'x':x, 'y':y, 'name':'A1'},), 1, 1)
fig.append_trace(go.Scatter({'x':x, 'y':y1, 'name':'B2'},), 2, 2)
fig.append_trace(go.Scatter({'x':x, 'y':y2, 'name':'A2'},), 2, 1)
fig.append_trace(go.Scatter({'x':x, 'y':y3, 'name':'B1'},), 1, 2)

fig['layout'].update(title='Multiple Subplots')
url = poff.plot(fig, filename="test23.html")

参考方案

这里的建议应该非常接近100%,至少就目前实际可行而言:

1.子图边框:fig_update_xaxes(mirror=True)

2.您已经接近目前的状态

3.副标签:fig['layout']['xaxis']['title']='Label x-axis 1'

情节:

密谋:如何在边框上添加边框和侧面标签,以及如何同步平移? - python

码:

#import plotly.offline as poff
#import plotly.tools as tls

from plotly.subplots import make_subplots
import plotly.graph_objects as go
import pandas as pd

x = list(range(10,20))
y = x
y1 = [10-i for i in x]
y2 = [abs(i-5) for i in x]
y3 = [abs(2*i- 5) for i in x]

fig = make_subplots(rows=2, cols=2, shared_xaxes=True, shared_yaxes=True,
                    #vertical_spacing=0.1,
                    #horizontal_spacing=0.05,
                    print_grid=True,)

fig.append_trace(go.Scatter({'x':x, 'y':y, 'name':'A1'},), 1, 1)
fig.append_trace(go.Scatter({'x':x, 'y':y1, 'name':'B2'},), 2, 2)
fig.append_trace(go.Scatter({'x':x, 'y':y2, 'name':'A2'},), 2, 1)
fig.append_trace(go.Scatter({'x':x, 'y':y3, 'name':'B1'},), 1, 2)

fig['layout'].update(title='Multiple Subplots')

fig.update_xaxes(showline=True, linewidth=1, linecolor='black', mirror=True)
fig.update_yaxes(showline=True, linewidth=1, linecolor='black', mirror=True)

# edit axis labels
fig['layout']['xaxis']['title']='Label x-axis 1'
fig['layout']['xaxis2']['title']='Label x-axis 2'

fig['layout']['xaxis3']['title']='Label x-axis 3'
fig['layout']['xaxis4']['title']='Label x-axis 4'

fig['layout']['yaxis']['title']='Label y-axis 1'
fig['layout']['yaxis2']['title']='Label y-axis 2'

fig['layout']['yaxis3']['title']='Label x-axis 3'
fig['layout']['yaxis4']['title']='Label x-axis 4'

fig.show()

在返回'Response'(Python)中传递多个参数 - python

我在Angular工作,正在使用Http请求和响应。是否可以在“响应”中发送多个参数。角度文件:this.http.get("api/agent/applicationaware").subscribe((data:any)... python文件:def get(request): ... return Response(seriali…

Python exchangelib在子文件夹中读取邮件 - python

我想从Outlook邮箱的子文件夹中读取邮件。Inbox ├──myfolder 我可以使用account.inbox.all()阅读收件箱,但我想阅读myfolder中的邮件我尝试了此页面folder部分中的内容,但无法正确完成https://pypi.python.org/pypi/exchangelib/ 参考方案 您需要首先掌握Folder的myfo…

python JSON对象必须是str,bytes或bytearray,而不是'dict - python

在Python 3中,要加载以前保存的json,如下所示:json.dumps(dictionary)输出是这样的{"('Hello',)": 6, "('Hi',)": 5}当我使用json.loads({"('Hello',)": 6,…

R'relaimpo'软件包的Python端口 - python

我需要计算Lindeman-Merenda-Gold(LMG)分数,以进行回归分析。我发现R语言的relaimpo包下有该文件。不幸的是,我对R没有任何经验。我检查了互联网,但找不到。这个程序包有python端口吗?如果不存在,是否可以通过python使用该包? python参考方案 最近,我遇到了pingouin库。

Python ThreadPoolExecutor抑制异常 - python

from concurrent.futures import ThreadPoolExecutor, wait, ALL_COMPLETED def div_zero(x): print('In div_zero') return x / 0 with ThreadPoolExecutor(max_workers=4) as execut…