- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试使用 matplotlib
的 xkcd
包绘制黑色背景图。然而,xkcd 似乎在文本和线条周围添加了一种白色轮廓线。在白色背景上你看不到这个白框,但在黑色背景上它真的很烦人。
有没有人知道如何解决这个问题?也许可以选择如何将白色轮廓线更改为具有背景颜色?
最小的例子:
import numpy as np
import matplotlib.pyplot as plt
plt.style.use(['dark_background'])
plt.xkcd()
plt.rcParams['figure.facecolor'] = 'black'
x = np.linspace(-5, 5)
plt.figure()
plt.plot(x, x**2)
plt.text(0, 10, "Text", color='r', fontsize=20)
plt.xlabel("$x$" )
plt.ylabel("$f(x)$")
plt.show();
:
编辑:我在我的 jupyter notebook 中使用 Python 3.5.4
包:
matplotlib==2.2.2
, backend='TkAgg'jupyter==1.0.0
notebook==5.5.0
请注意,当将上述代码作为脚本运行时,我以某种方式根本没有得到 xkcd 图。只有从 jupyter notebook 或命令行我才能得到描述的行为。
最佳答案
在你给出plt.xkcd()
命令后,尝试执行
from matplotlib import patheffects
plt.rcParams['path.effects'] = [patheffects.withStroke(linewidth=0)]
这解决了我的问题!
编辑:我根据建议的更改运行了您提供的代码。
输入:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import patheffects
plt.style.use(['dark_background'])
plt.xkcd()
plt.rcParams['path.effects'] = [patheffects.withStroke(linewidth=0)]
plt.rcParams['figure.facecolor'] = 'black'
x = np.linspace(-5, 5)
plt.figure()
plt.plot(x, x**2)
plt.text(0, 10, "Text", color='r', fontsize=20)
plt.xlabel("$x$" )
plt.ylabel("$f(x)$")
plt.show();
输出(抱歉,我必须链接到输出图像,因为 Stack 上的新手不允许在他们的答案中嵌入图像):
You might want to change your axis colors to white, though, if you want the background to be black
关于python - matplotlib xkcd和黑图背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50845646/
所以 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
我是一名优秀的程序员,十分优秀!