(使用 Python 3.0)以 0.25 为增量,我想计算和绘制指定范围内给定数据的 PDF 以便于可视化。
多亏了 SO 社区,已经完成了计算单个图的工作,但是我不能完全正确地使算法正确地在值范围内进行迭代。
数据:https ://www.dropbox.com/s/y78pynq9onyw9iu/Data.csv?dl=0
到目前为止,我所拥有的是标准化玩具数据,看起来像霰弹枪爆炸,其中一个目标区域隔离在黑线之间,增量为 0.25:
import csv
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import pyplot as plt
import seaborn as sns
Data=pd.read_csv("Data.csv")
g = sns.jointplot(x="x", y="y", data=Data)
bottom_lim = 0
top_lim = 0.25
temp = Data.loc[(Data.y>=bottom_lim)&(Data.y<top_lim)]
g.ax_joint.axhline(top_lim, c='k', lw=2)
g.ax_joint.axhline(bottom_lim, c='k', lw=2)
# we have to create a secondary y-axis to the joint-plot, otherwise the kde
might be very small compared to the scale of the original y-axis
ax_joint_2 = g.ax_joint.twinx()
sns.kdeplot(temp.x, shade=True, color='red', ax=ax_joint_2, legend=False)
ax_joint_2.spines['right'].set_visible(False)
ax_joint_2.spines['top'].set_visible(False)
ax_joint_2.yaxis.set_visible(False)
现在我想要做的是在每个 0.25 数据带上绘制这些数据的山脊线/欢乐图。
我从各种 Seaborn 示例中尝试了一些技术,但没有真正将带或值范围解释为 y 轴。结果,我正在努力将我的书面算法翻译成工作代码。