找到 784 篇文章,关于数据可视化

如何在 Matplotlib 的 factorplot 中分别更改线宽和标记大小?

Rishikesh Kumar Rishi
更新于 2021年6月18日 10:36:55

208 次浏览

要分别更改 factorplot 中的线宽和标记大小,我们可以使用以下步骤:设置图形大小并调整子图之间和周围的填充。从在线存储库加载示例数据集。使用 factorplot() 方法和 scale 来更改标记大小。要显示图形,请使用 show() 方法。示例import seaborn as sns from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True exercise = sns.load_dataset("exercise") g = sns.factorplot(x="time", y="pulse", hue="kind", data=exercise, ci=95,                   markers=['o', '*', 'd'],                 ... 阅读更多

如何在 Pandas 中绘制多个条形图时更改条形之间的间距?(Matplotlib)

Rishikesh Kumar Rishi
更新于 2021年6月18日 10:36:13

6K+ 次浏览

要在 Pandas 中在一个组内绘制多个条形图时更改条形之间的间距,我们可以在 plot() 方法中使用 linewidth。步骤设置图形大小并调整子图之间和周围的填充。创建一个包含两列的字典。创建一个二维、大小可变的、可能是异构的表格数据。使用 plot() 方法绘制数据框,并使用 linewidth 来更改条形之间的间距。在图上放置一个图例。要显示图形,请使用 show() 方法。示例import pandas as pd from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True d = {'Column 1': [i for i in range(10)],     ... 阅读更多

如何在 Windows 上使用 Conda 安装 Matplotlib 而不安装 Qt?

Rishikesh Kumar Rishi
更新于 2021年6月18日 10:35:43

491 次浏览

要使用 Conda 安装 Matplotlib 包,请运行以下命令之一:conda install -c conda-forge matplotlib-base conda install -c conda-forge/label/testing matplotlib-base conda install -c conda-forge/label/testing/gcc7 matplotlib-base conda install -c conda-forge/label/cf202003 matplotlib-base conda install -c conda-forge/label/matplotlib_rc matplotlib-base conda install -c conda-forge/label/gcc7 matplotlib-base conda install -c conda-forge/label/broken matplotlib-base conda install -c conda-forge/label/matplotlib-base_rc matplotlib-base conda install -c conda-forge/label/rc matplotlib-base conda install -c conda-forge/label/cf201901 matplotlib-base

如何在 Matplotlib 中重用绘图?

Rishikesh Kumar Rishi
更新于 2021年6月18日 10:35:15

1K+ 次浏览

要在 Matplotlib 中重用绘图,我们可以采取以下步骤:设置图形大小并调整子图之间和周围的填充。使用 figure() 方法创建新图形或激活现有图形。使用一些输入列表绘制一条线。要重用绘图,请更新 y 数据和绘图的线宽。要显示图形,请使用 show() 方法。示例from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True line, = plt.plot([1, 3], [3, 4], label="line plot", color='red', lw=0.5) line.set_ydata([3.5]) line.set_linewidth(4) plt.show()输出

如何在创建后修改 Matplotlib 图例?

Rishikesh Kumar Rishi
更新于 2021年6月18日 10:34:44

2K+ 次浏览

要在创建后修改 Matplotlib 图例,我们可以有多种方法来修改已创建的图例。设置图形大小并调整子图之间和周围的填充。使用 plot() 方法绘制一条线,其中包含两个列表和一个标签。使用 legend() 方法在图上放置一个图例。要修改 matplotlib 图例,请使用 set_title() 方法。要显示图形,请使用 show() 方法。示例from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True plt.plot([1, 3, 4, 5, 2, 1], [3, 4, 1, 3, 0, 1],          label="line plot", color='red', lw=0.5) ... 阅读更多

使用 Seaborn FacetGrid 绘制数据框中的误差条(Matplotlib)

Rishikesh Kumar Rishi
更新于 2021年6月18日 10:34:13

459 次浏览

要使用 Seaborn FacetGrid 绘制数据框中的误差条,我们可以使用以下步骤:获取二维、大小可变的、可能是异构的表格数据。用于绘制条件关系的多图网格。将绘图函数应用于数据的每个方面的子集。要显示图形,请使用 show() 方法。示例import pandas as pd import seaborn as sns from matplotlib import pyplot as plt df = pd.DataFrame({'col1': [3.0, 7.0, 8.0],                   'col2': [1.0, 4.0, 3.0]}) g = sns.FacetGrid(df, col="col1", hue="col1") g.map(plt.errorbar, "col1", "col2", yerr=0.75, fmt='o') plt.show()输出

如何在控制台应用程序上显示 pyplot 图像?(Matplotlib)

Rishikesh Kumar Rishi
更新于 2021年6月18日 10:33:06

2K+ 次浏览

要在控制台上显示 pyplot 图像,我们可以使用 pyplot.show() 方法。步骤设置图形大小并调整子图之间和周围的填充。创建 5×5 维度的随机数据。使用 imshow() 方法和数据。将数据显示为图像,即在二维规则光栅上。要显示图形,请使用 show() 方法。示例import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True data = np.random.rand(5, 5) plt.imshow(data, cmap="copper") plt.show()输出

如何在 Python 中绘制用 def 定义的函数?(Matplotlib)

Rishikesh Kumar Rishi
更新于 2023年8月24日 16:23:56

66K+ 次浏览

要在 Python 中绘制用 def 定义的函数,我们可以采取以下步骤:设置图形大小并调整子图之间和周围的填充。使用 def 创建用户定义的函数,即 f(x)。使用 numpy 创建 x 数据点。使用 plot() 方法绘制 x 和 f(x)。要显示图形,请使用 show() 方法。示例import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True def f(x):    return np.sin(x) + x + x * np.sin(x) x = np.linspace(-10, 10, 100) plt.plot(x, f(x), color='red') plt.show()输出阅读更多

如何在 Matplotlib 中生成条形码?

Rishikesh Kumar Rishi
更新于 2021年6月18日 10:31:51

299 次浏览

要在 Matplotlib 中生成条形码,我们可以采取以下步骤:设置图形大小并调整子图之间和周围的填充。创建一个二进制数字列表,即 0 和 1。使用 dpi=100 创建一个新图形或激活现有图形。关闭轴。使用 imshow() 方法绘制步骤 2 中的数据。要显示图形,请使用 show() 方法。示例import matplotlib.pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True code = np.array([ 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, ... 阅读更多

如何在 Matplotlib 中为已绘制的线设置标签?

Rishikesh Kumar Rishi
更新于 2021年6月17日 12:09:33

1K+ 次浏览

要在 Matplotlib 中为已绘制的线设置标签,我们可以采取以下步骤:设置图形大小并调整子图之间和周围的填充。使用输入列表绘制线条。设置已创建线的标签。在“右上方”位置在图上放置一个图例。要显示图形,请使用 show() 方法。示例from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True line, = plt.plot([2, -1, 4, -1, 2]) line.set_label("line") plt.legend(loc="upper right") plt.show()输出

广告
© . All rights reserved.