python - 从 matplotlib 图中删除白色背景

标签 python numpy matplotlib graph-visualization

我正在尝试绘制透明图形,但背景中出现了一些框,并且外框没有出现。如何从图中删除白色背景并使其透明并放置外框?

from matplotlib import pyplot
pyplot.scatter(Neural_Net, y_test)
pyplot.xlabel('Actual', fontsize=15)
pyplot.ylabel('Predicted', fontsize=15)
pyplot.show()

Output

最佳答案

默认的matplotlib styleclassic

您可以看到可用的matplotlib样式

import matplotlib.pyplot as plt

#To list all available styles, use:

print(plt.style.available)
['Solarize_Light2', '_classic_test_patch', 'bmh', 'classic', 'dark_background', 'fast', 'fivethirtyeight', 'ggplot', 'grayscale', 'seaborn', 'seaborn-bright', 'seaborn-colorblind', 'seaborn-dark', 'seaborn-dark-palette', 'seaborn-darkgrid', 'seaborn-deep', 'seaborn-muted', 'seaborn-notebook', 'seaborn-paper', 'seaborn-pastel', 'seaborn-poster', 'seaborn-talk', 'seaborn-ticks', 'seaborn-white', 'seaborn-whitegrid', 'tableau-colorblind10']

要改回默认的白色背景:

plt.style.use('classic')

希望有帮助!

关于python - 从 matplotlib 图中删除白色背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61203720/

相关文章:

Python:写入文件时的内存使用情况(生成器与列表)

python - 删除迁移后 makemigrations 不起作用

python - 2 个矩阵中行的点积

python - 如何在 matplotlib 中 'turn off' imshow() 的模糊效果?

python - 任意颜色条

使用类点的 Python Sierpinski 三角形

python - 使用 scipy/numpy 在 Python 中将数组的值设置为 -inf

python - 有效地从 np 数组中删除零

python - 如何使用Python pylab模块在boxplot中设置xticks的fontSize?

python - Matplotlib 坐标变换