- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
将 xkcd() 与 matplotpib 一起使用时,没有任何字体以通常的漫画字体显示。有什么变化还是我做错了什么?
x = df['Time']
y = df['Adjustment']
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax1 = fig.add_subplot(1,1,1)
ax1.plot(x,y)
ax1.xaxis.set_visible(False)
ax1.yaxis.set_visible(False)
plt.axvline(x=2.3, color='k', ls='dashed')
plt.axvline(x=6, color='k', ls='dashed')
ax.text(4,4,'Culture Shock', size=16)
plt.title('Test title')
plt.xkcd()
plt.show()
感谢您的帮助。
我应该澄清一下,图表将以 xkcd 样式绘制,而不是任何字体。它打印出类似于 Times New Roman 的内容。
最佳答案
作为examples show ,您需要将 plt.xkcd()
放在代码的开头,在所有绘图命令之前。因此:
from matplotlib import pyplot as plt
import numpy as np
x = np.arange(10)
y = np.sin(x)
plt.xkcd()
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax1 = fig.add_subplot(1,1,1)
ax1.plot(x,y)
ax1.xaxis.set_visible(False)
ax1.yaxis.set_visible(False)
plt.axvline(x=2.3, color='k', ls='dashed')
plt.axvline(x=6, color='k', ls='dashed')
ax.text(4,4,'Culture Shock', size=16)
plt.title('Test title')
plt.show()
这对我来说是这个数字:
如您所见,那里有摇摆不定的线条,但字体是错误的,只是因为它在我的 Linux 机器上不可用(我还在命令行上收到了关于此的警告)。将 plt.xkcd()
放在代码末尾会生成简单明了的 matplotlib 图,没有摇摆不定的线条。
下面是 pyplot.xkcd()
的工作总结;它只是设置了很多资源参数:
rcParams['font.family'] = ['Humor Sans', 'Comic Sans MS']
rcParams['font.size'] = 14.0
rcParams['path.sketch'] = (scale, length, randomness)
rcParams['path.effects'] = [
patheffects.withStroke(linewidth=4, foreground="w")]
rcParams['axes.linewidth'] = 1.5
rcParams['lines.linewidth'] = 2.0
rcParams['figure.facecolor'] = 'white'
rcParams['grid.linewidth'] = 0.0
rcParams['axes.unicode_minus'] = False
rcParams['axes.color_cycle'] = ['b', 'r', 'c', 'm']
rcParams['xtick.major.size'] = 8
rcParams['xtick.major.width'] = 3
rcParams['ytick.major.size'] = 8
rcParams['ytick.major.width'] = 3
关于python - Matplotlib 文本不会以 xkcd 字体显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25679403/
所以 2013 年 4 月 1 日 xkcd Externalities网络漫画以 Skein 1024 1024 散列为特色 contest .我假设这一定只是一种蛮力的努力,其中随机字符串被散列以
流行的漫画 xkcd 提出了这个将时间完整转换为日期的等式: 我一直在尝试在 JavaScript 中做同样的事情,尽管我不断得到 -Infinity。这是代码: var p = 5; // Perc
我按照小插图中给出的说明尝试使用 xkcd 字体:vignette("xkcd-intro") 但是在以下步骤中出现错误: > system("cp xkcd.tff -t ~/.fonts") cp
我想创建图表,就像在 link对于上一个主题,但收到错误: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : Font
关于xkcd site今天,以下内容作为笑话出现在 标签 那么下面的代码做什么/代表什么? (define (eval exp env) (cond ((self-evaluating? e
我想在背景中创建一些带有网格的 xkcd 图。像这样example , 但当 plt.xkcd()网格没有出现在图中。 from matplotlib import pyplot as plt imp
我正在尝试让 matplotlib xkcd 函数正常工作,在安装所有必要的东西之后执行此操作。 http://matplotlib.org/xkcd/examples/showcase/xkcd.h
我一直在使用 matplotlib 中的 xkcd 样式功能。我有 Matplotlib 1.4,并且 humor sans 字体安装正确,或者至少可以在 msword 中使用。 当我运行以下示例代码
将 xkcd() 与 matplotpib 一起使用时,没有任何字体以通常的漫画字体显示。有什么变化还是我做错了什么? x = df['Time'] y = df['Adjustmen
当我像这样制作一个简单的 xkcd 图时: import matplotlib.pyplot as plt plt.xkcd() plt.plot(range(10), range(10)) plt.
如此有才华的人已经想出了如何制作xkcd样式图 in Mathematica , in LaTeX , in Python和 in R已经。 如何使用 MATLAB 绘制如上图所示的绘图? 我尝试过的
由于第 9 行中的 double 换行符,以下 python3 代码不起作用: # -*- coding: utf-8 -*- from matplotlib import pyplot as plt
好吧,我知道这个问题已经被问过很多次了,但我没有得到这个工作: 我尝试在 Ubuntu 16.04 LTS 64-bit 和 python 2.7.12 64- 上的 matplotlib 中使用
您通过以下方式打开 xkcd 样式: import matplotlib.pyplot as plt plt.xkcd() 但是如何禁用它呢? 我尝试: self.fig.clf() 但它不会起作用。
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 9 年前。 Improve this
matplotlib (1.3.1) 的当前版本支持 xkcd 风格的绘图,但是当我 follow the basic instructions用于生成这样的图(在 iPython 1.1.0 中),
已关闭。这个问题是 off-topic 。目前不接受答案。 想要改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 已关闭11 年前。 Improve th
我正在尝试抓取 xkcd.com 以检索他们可用的所有图像。当我运行抓取工具时,它会下载 www.xkcd.com/1-1461 范围内的 7-8 个随机图像。我希望它能够连续浏览每一页并保存图像以确
我正在尝试从 xkcd.com 网站获取主图像的 src(URL) 链接。我正在使用以下代码,但它返回类似 session="2f69dd2e-b377-4d1f-9779-16dad1965b81"
我已经设法在以下位置复制图表: http://matplotlib.org/xkcd/examples/showcase/xkcd.html 但是我的字体看起来不像那样。如何将文本字体更改为炫酷的 x
我是一名优秀的程序员,十分优秀!