python - 在 seaborn 的分类图上使用不规则间隔的非分类轴

标签 python matplotlib python-3.6 seaborn

我在 Seaborn 中创建了一个 fiddle 图,默认情况下,它假定 x 轴是分类的,因此均匀分布数据,而不是按值缩放。我希望各个 fiddle 之间的间距由与每把 fiddle 关联的值来定义,而不是仅仅将它们均匀分布。我读过一些建议我可以用 matplotlib 命令覆盖默认值的东西,但无法使任何东西工作。

sns.set(palette='muted', color_codes=True)
f, axes = plt.subplots(2, 2, figsize=(8,5))
sns.violinplot(x = lsdf['6MO_CUM_MBO/1000FT'], y = lsdf.RELATIVE_DEPTH,
data=lsdf, palette="Blues", ax=axes[0,0])

我认为这里的关键问题是我不确定 Seaborn 的默认值在控制什么。我是否需要修改由子图创建的轴对象?还是 ax=[0,0] 对象?

我找到的类似问题的唯一答案是“在 matplotlib 中执行”,但我需要 seaborn 中可用的图。感谢您的帮助。

seaborn categorical violin plot

最佳答案

好吧,我最终解决了这个问题,有点……我屈服了,使用了纯 matplotlib,放弃了 Seaborn。 matplotlib violinplot 采用类似数组的 positions 参数,当传递数值时,它会自动缩放 x 轴并表现得与 plt.plot 或标记位置的任何图完全一样和轴范围来自输入数据。我仍然使用 seaborn.set() 来获得漂亮的 Seaborn 美学。有matplotlib fiddle 情节定制documentation它有很好的例子说明如何编辑 fiddle 的细节,这让我可以自定义 fiddle 并模仿 Seaborn fiddle 情节的所有部分。

关于python - 在 seaborn 的分类图上使用不规则间隔的非分类轴,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51412287/

相关文章:

python - 问题 unpickling 对象

numpy - Keras(Numpy 输入)TypeError : Error converting shape to a TensorShape: int() argument must be a string, 类字节对象或数字,而不是 'tuple'

python - Pycharm anaconda导入 tensorflow 库问题

python从id的日期范围中找到唯一的日期

python - 如何在 Python 中绘制 ROC 曲线

python - Matplotlib 条形图 - 一些条形不可见并且宽度似乎不同

python - 让不和谐的机器人每 10 秒改变一次播放状态

python - Tkinter StringVar 获取所选选项的索引

python - GAE : remote_api_shell. py 使用了错误的 Django 版本

matplotlib - 可视化 :-x-labels and title for the graph created through matplotlib and seaborn are not displaying properly