【问题标题】:Seaborn: How to change linewidth and markersize separately in factorplot?Seaborn:如何在因子图中分别更改线宽和标记大小?
【发布时间】:2016-07-24 19:55:13
【问题描述】:

我知道scale同时改变了两个参数,但是我想达到在大标记之间连接细线的效果。

我也尝试通过rc{'lines.linewidth' = 1, 'lines.markersize' = 5} 调整大小,但它最终将标记大小和线宽缩放在一起,而不是单独设置它们。从本质上讲,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)                                                       

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

【问题讨论】:

  • 解决方案:link

标签: python matplotlib seaborn


【解决方案1】:

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

使用 matplotlib,您可以在同一个图形上制作 2 个图,一个散点图(任意标记大小)和一个任意线宽的线图

希望对你有帮助

【讨论】:

    猜你喜欢
    • 2023-03-10
    • 1970-01-01
    • 2016-04-20
    • 2017-06-30
    • 2016-01-25
    • 2014-08-28
    • 2014-12-19
    • 2020-05-24
    相关资源
    最近更新 更多