matplotlib -Pandas-如何在一个图中创建多标签?
这是我的代码:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from numpy.random import randn
df = pd.read_csv(r"XXXXXXX.txt")
df.plot(x='qPkw', y='vPkw', kind='scatter', figsize=(12, 12), use_index=True,
title="q-v-Diagram (Pkw)", xticks=[0, 25, 50, 75, 100, 125], yticks=[0, 100, 200, 300, 400, 500],
xlabel="v-Pkw", ylabel="q-Pkw", fontsize=15, color="black", label="Pkw")
df.plot(x='qLkw', y='vLkw', kind = 'scatter', figsize=(12, 12), use_index=True,
title="q-v-Diagram (Lkw)", xticks=[0, 5, 10, 15, 20, 25, 30], yticks=[0, 100, 200, 300, 400],
xlabel="v-Lkw", ylabel="q-Lkw", fontsize= 15, color="blue", label="Lkw")
plt.show()
而不是一个,我得到了两个图。
我只想将这两个图中的这两个图。 我也想标记这两个。
有人看到错误吗?
This is my code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from numpy.random import randn
df = pd.read_csv(r"XXXXXXX.txt")
df.plot(x='qPkw', y='vPkw', kind='scatter', figsize=(12, 12), use_index=True,
title="q-v-Diagram (Pkw)", xticks=[0, 25, 50, 75, 100, 125], yticks=[0, 100, 200, 300, 400, 500],
xlabel="v-Pkw", ylabel="q-Pkw", fontsize=15, color="black", label="Pkw")
df.plot(x='qLkw', y='vLkw', kind = 'scatter', figsize=(12, 12), use_index=True,
title="q-v-Diagram (Lkw)", xticks=[0, 5, 10, 15, 20, 25, 30], yticks=[0, 100, 200, 300, 400],
xlabel="v-Lkw", ylabel="q-Lkw", fontsize= 15, color="blue", label="Lkw")
plt.show()
Instead of one, I get two plots.
I just want to have these two in one plot.
Also I want to label these two.
Someone sees the mistake?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
捕获第一个轴,并在第二个轴上使用
ax
关键字。请注意,将忽略第一个Xticks和Yticks设置。 Xlabel和Ylabel也是如此。这是一个数字,因为它是一个数字。
Capture the first axis, and use the
ax
keyword in the second plot with the first axis.Be aware that the first xticks and yticks settings will be ignored. The same for the xlabel and ylabel. That has to be, since it is in one figure.