标签: scatter-plot

增加 ggplot2 中数字图例的级别

我想在我的 ggplot 中包含更详细的图例。当前的图例并不代表我所有的点尺寸。在以下示例中:

df <- "Freq Obs NumberOfWindows
        15 0.5  40
        12 0.4  80
        10 0.3  100
        8  0.2  800
       6   0.18 1300
       3   0.1  2000
       1   0.05 30000"

ResA <- read.table(text=df, header=T)


library(ggplot2)

 ggplot(ResA, aes(Freq, Obs, size=NumberOfWindows)) +
  geom_point() +
  xlab("Boundary frequency") +
  ylab("Average number of overlaps per window (10kb)") +
  ggtitle(as.character("The plot"))+ 
  theme_bw()+
  scale_size_continuous(name="area", range = c(1,20))
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

请注意,我的数字范围从 40 到 30000。我在那里有很大的差异,但是,我希望在图例中至少有最大和最小的点。否则图例对小点没有多大帮助。这里的任何想法都受到高度赞赏。

r scatter-plot ggplot2

0
推荐指数
1
解决办法
677
查看次数

如何在 matplolib python 上制作抖动图

这是我的代码(改编自此处):

\n\n
df_1 = pd.DataFrame({\'Cells\' : np.arange(0,100), \'Delta_7\' : np.random.rand(100,), \'Delta_10\' : np.random.rand(100,), \'Delta_14\' : np.random.rand(100,)}, columns = [\'Cells\',\'Delta_7\', \'Delta_10\', \'Delta_14\'])\n\n\n\n#figure\nfig, ax1 = plt.subplots()\nfig.set_size_inches(13, 10)\n\n\n\n#c sequence\nc = df_1[\'Delta_7\']\n\n#plot\n\nplt.scatter(np.full((len(df_1), 1), 1), df_1[\'Delta_7\'] , s = 50, c=c, cmap = \'viridis\')\nplt.scatter(np.full((len(df_1), 1), 2), df_1[\'Delta_10\'] , s = 50, c=c, cmap = \'viridis\')\nplt.scatter(np.full((len(df_1), 1), 3), df_1[\'Delta_14\'] , s = 50, c=c, cmap = \'viridis\')\ncbar = plt.colorbar()\n
Run Code Online (Sandbox Code Playgroud)\n\n

我想用 matplotlib 制作一个漂亮的抖动图(就像在Rseaborn上一样)。问题是我想根据每个单元格的“Delta_7”值给每个单元格一个颜色。当绘制“Delta_10”和“Delta_14”时,这种颜色将被保留,而我没有设法用seaborn做到这一点。\n如果您有任何线索(python包,编码),请告诉我技巧\xe2\x80\xa6)?

\n\n

亲切地,

\n

python matplotlib scatter-plot

0
推荐指数
1
解决办法
3168
查看次数

Plot Multiple Y axis + 'hue' scatterplot

Dataframe

df
Sample Type   y1   y2   y3  y4
S1     H     1000  135  220  171
S2     H     2900  1560 890  194
S3     P     678   350  127  255
S4     P     179   510  154  275
Run Code Online (Sandbox Code Playgroud)

I want to plot y1, y2, y3, y4 vs Sample scatterplot with hue as Type.

Is there any way to do it in Seaborn?

python scatter-plot pandas seaborn relplot

0
推荐指数
1
解决办法
3703
查看次数

如何使 geom_point 散点图中的点取决于计数?

我正在使用 ggplot 创建数据框的散点图。x 轴和 y 轴是框架中的两列,以下代码给出了散点图:

ggplot(df,aes(x=Season,y=type))+
  geom_point(fill="blue")
Run Code Online (Sandbox Code Playgroud)

但这些点的大小都是相同的。我希望每个点取决于与 x 和 y 的组合匹配的行数。有人知道怎么做吗?

r scatter-plot ggplot2 geom-point

0
推荐指数
1
解决办法
550
查看次数

具有可变标记颜色和大小以及图例的 Python 散点图

我想从 x 和 y 创建一个散点图,具有以下特征:

  • 标记大小变量(根据对应于 (x,y) 对的值 z)
  • 标记颜色变量(根据对应于 (x,y) 对的类别 c)
  • 包括显示 c 的不同值以及它们如何与颜色匹配的图例

关于如何将这 3 个要求中的 2 个结合起来,我找到了很多答案。但是,我还没有看到它们全部联合实施,无论是在 seaborn 还是在 matplotlib 上。

python matplotlib scatter-plot seaborn

-2
推荐指数
1
解决办法
2572
查看次数

标签 统计

scatter-plot ×5

python ×3

ggplot2 ×2

matplotlib ×2

r ×2

seaborn ×2

geom-point ×1

pandas ×1

relplot ×1