【问题标题】:Cartoonish style plots in MATLAB or Python? [duplicate]MATLAB 或 Python 中的卡通风格绘图? [复制]
【发布时间】:2014-02-05 13:55:25
【问题描述】:

Mathematica here 上有一篇很棒的帖子,介绍了如何使情节和图表对观众更加卡通化和温暖。

我想知道是否有人知道我们可以在 MATLAB 或 python 中执行此操作的类似方法。这样的事情可能吗? (也称为xkcd-style plots)

【问题讨论】:

标签: python matlab matplotlib plot


【解决方案1】:

是的(至少在 Python 中)!

这是一个简单的例子(基本上是从 pyplot 教程中提取的):

import numpy as np
import matplotlib.pyplot as plt

# evenly sampled time at 200ms intervals
t = np.arange(0., 5., 0.2)

plt.xkcd(scale=1, length=100, randomness=2)

plt.plot(t, t, 'r', t, t**2, 'b', t, t**3, 'g')
plt.show()

只要确保你有足够新的 matplotlib 版本就可以了

这里是关于 xkcd 函数的文档 - http://matplotlib.org/api/pyplot_api.html?highlight=xkcd#matplotlib.pyplot.xkcd

当我在我的电脑上运行上面的代码时,我看到:

【讨论】:

  • 哇!我想你终于说服我学习 Python 了! :-)
  • 你真的可以制作你在mathematica帖子中看到的那些相同类型的图/图吗?
  • matplotlib.org/xkcd/gallery.html。这是一组在 matplotlib 中制作的 xkcd 类型图。我没有看到帖子中的确切内容,但是是的,我确信你可以做到。
  • 我不明白为什么不这样做。定义曲线(调整numpy数组)然后添加cmets只是一个不同的系列。因此可以添加评论:matplotlib.org/users/text_intro.html(根据我嵌入的链接,您可能需要获得不同的字体才能真正让它看起来不错)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-08-22
  • 2022-01-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-02-04
  • 1970-01-01
相关资源
最近更新 更多