如何更改标记边框宽度和填充宽度? [英] How to change marker border width and hatch width?

查看:49
本文介绍了如何更改标记边框宽度和填充宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此散点图中标记的示例中,我将颜色设置为绿色,将边缘颜色设置为黑色,并将阴影线设置为"|".为了完全显示填充图案,我必须设置边缘颜色,但是当我这样做时,我会在标记周围得到一个非常粗的边框.两个问题:

In this example of a marker from my scatter plot I have set the color to green, and edge color to black, and hatch to "|". For the hatch pattern to show up at all I must set the edgecolor, however when I do, I get a very thick border around the marker. Two questions:

1) 如何设置此边框的大小(最好为 0)?

1) How can I to set the size of this border (preferably to 0)?

2)如何增加剖面线的宽度?

2) How can I increase the thickness of the hatch lines?

推荐答案

  1. 您只需要设置 linewidth 即可控制标记边框的粗细.
  2. 您可以通过重复符号来增加阴影的密度(在下面的示例中,'|' 在 R/H 窗格中重复;请注意,要获得 NW->SE 对角线必须对符号进行转义,因此需要两倍的字符才能真正将其加倍 -- '\\\\' 是密度 2 而 '||||' 是密度4).但是,我不认为影线内各条线的粗细是可控的.
  1. You just need to set the linewidth to control the marker border thickness.
  2. You can increase the density of hatching, by repeating symbols (in the example below, the '|' is repeated in the R/H pane; note that to obtain NW->SE diagonal lines the symbol must be escaped so needs twice as many characters to really double it -- '\\\\' is density 2 while '||||' is density 4). However, I don't think the thickness of individual lines within hatching is controllable.

请参阅下面的代码示例以生成如下散点图:

See the code example below to produce scatter plots such as these:

import matplotlib.pyplot as plt
# generate some data
x = [1,2,3,4,5,8]
y= [i**2 for i in x]
y2= [60-i**2+3*i for i in x]

# plot markers with thick borders
plt.subplot(121)
plt.scatter(x,y, s=500, marker='s', edgecolor='black', linewidth=3, facecolor='green', hatch='|')
# compare with no borders, and denser hatch.
plt.subplot(122)
plt.scatter(x,y2, s=500, marker='s', edgecolor='black', linewidth=0, facecolor='green', hatch='||||')

plt.show()

收藏上的

matplotlib文档和散布.

这篇关于如何更改标记边框宽度和填充宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆