python自定义结束符号_python – Matplotlib自定义标记/符号

所以发现它只是使用数学符号,而不是指存储在matplotlib模块中的任何分开的基于矢量的标记。

from matplotlib import pyplot as plt

import numpy as np

from numpy.random import randint

import matplotlib

x = np.arange(0.0, 100.0, 2.0)

y = x ** 1.3 + np.random.rand(*x.shape) * 30.0

s = np.random.rand(*x.shape) * 800 + 500

markers = ['\\alpha', '\\beta', '\gamma', '\sigma','\infty', \

'\spadesuit', '\heartsuit', '\diamondsuit', '\clubsuit', \

'\\bigodot', '\\bigotimes', '\\bigoplus', '\imath', '\\bowtie', \

'\\bigtriangleup', '\\bigtriangledown', '\oslash' \

'\ast', '\\times', '\circ', '\\bullet', '\star', '+', \

'\Theta', '\Xi', '\Phi', \

'\$', '\#', '\%', '\S']

def getRandomMarker():

return "$"+markers[randint(0,len(markers),1)]+"$"

def getMarker(i):

# Use modulus in order not to have the index exceeding the lenght of the list (markers)

return "$"+markers[i % len(markers)]+"$"

for i, mi in enumerate(markers):

plt.plot(x[i], y[i], "b", alpha=0.5, marker=getRandomMarker(), markersize=randint(16,26,1))

plt.plot(x[i], y[i]+50, "m", alpha=0.5, marker=getMarker(i), markersize=randint(16,26,1))

# Let's see if their "center" is located where we expect them to be...

plt.plot(x[i], y[i]+100, "y", alpha=0.5, marker=getMarker(i), markersize=24)

plt.plot(x[i], y[i]+100, "k+", markersize=12, markeredgewidth=2)

plt.xlabel("x-axis")

plt.ylabel("y-axis")

plt.xlim( -5, plt.xlim()[1]+5 )

plt.ylim( 0, plt.ylim()[1]*1.1 )

gcf().set_size_inches(12,6)

plt.show()

不要忘记投票,如果你发现这个答案有用.. thx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值