Seaborn:如何在FactoryPlot中分别更改线宽和标记大小?

2024-05-18 23:31:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我知道scale同时改变了这两个参数,但我想实现在大标记之间连接一条细线的效果。

我也尝试过通过rc{'lines.linewidth' = 1, 'lines.markersize' = 5}调整大小,但结果是同时缩放markersize和linewidth,而不是单独设置它们。本质上,markersize由于某种原因没有效果。

编辑:添加绘图和代码以显示问题

import seaborn as sns                                                      

sns.set(style="whitegrid")                                                 
paper_rc = {'lines.linewidth': 1, 'lines.markersize': 10}                  
sns.set_context("paper", rc = paper_rc)                                    

# Load the example exercise dataset                                        
df = sns.load_dataset("exercise")                                          

# Draw a pointplot to show pulse as a function of three categorical         factors
g = sns.factorplot(x="time", y="pulse", hue="kind", col="diet", data=df,   
                       palette="YlGnBu_d", size=6, aspect=.75)         
g.despine(left=True)                                                       

下面的前两个图分别用markersize 1和10创建。如图所示,它们的标记大小似乎相同。最后一个图使用line.linewidth=10 line.markersize=1,它同时放大了线宽和标记大小。

Marker Size 1

Marker Size 10

Marker and line size 10


Tags: 标记dfaslinedatasetpaperpulserc
1条回答
网友
1楼 · 发布于 2024-05-18 23:31:49

您可以导入seaborn以获得漂亮的布局,并使用matplotlib进行绘图,以获得更简单/更好的配置工具。

使用matplotlib,您只需在同一图形上绘制两个图,一个散点图(markersize任意)和一个线条图(linewidth任意)

希望能帮上忙

相关问题 更多 >

    热门问题