我已经复制了RidgePlot示例,并根据需要采用了它。我已经包含了工作脚本和一些示例数据进行测试。
图像:
我的一些数据的 y 值等于 0.0。我想在我的情节中强调这一点。我不确定绘图的哪个部分,或者只是每个x轴都可以更改,例如删除那些地方的映射颜色。fill_between"aandeel" == 0.0
关于如何在这里删除颜色的任何想法?是否可以简单地删除x轴/将宽度设置为0/将颜色更改为不同?
示例数据 (csv):https://gist.github.com/willemvanopstal/c2892e68d6eb94194acd371e49d949bd
import pandas as pd
from matplotlib import pyplot as plt
import seaborn as sns
import numpy as np
sns.set(style="whitegrid", rc={"axes.facecolor": (0, 0, 0, 0)})
data = pd.read_csv('stats_together_data.csv', delimiter=';')
df = data
# Initialize the FacetGrid object
pal = sns.color_palette("Set2")
g = sns.FacetGrid(df, row="process", hue="process", aspect=10, height=0.6, palette=pal)
# Draw the densities in a few steps
g.map(sns.lineplot, "region", "aandeel", clip_on=False, alpha=1, lw=1.5)
g.map(plt.fill_between, "region", "aandeel", interpolate=True)
g.map(sns.lineplot, "region", "aandeel", clip_on=False, color="w", lw=2)
g.map(plt.axhline, y=0, lw=1, clip_on=False)
# Define and use a simple function to label the plot in axes coordinates
def label(x, color, label):
ax = plt.gca()
ax.text(0, .2, label, fontweight="bold", color=color,
ha="left", va="center", transform=ax.transAxes)
g.map(label, "region")
# Set the subplots to overlap
g.fig.subplots_adjust(hspace=-.25)
# Remove axes details that don't play well with overlap
g.set_titles("")
g.set(yticks=[])
g.set(xticks=df.region[0::1])
g.despine(bottom=True, left=True)
plt.show()
一只甜甜圈
相关分类