matplotlib

How to visualize a list of strings on a colorbar in matplotlib

别来无恙 提交于 2021-02-17 05:20:11
问题 I have a dataset like x = 3,4,6,77,3 y = 8,5,2,5,5 labels = "null","exit","power","smile","null" Then I use from matplotlib import pyplot as plt plt.scatter(x,y) colorbar = plt.colorbar(labels) plt.show() to make a scatter plot, but cannot make colorbar showing labels as its colors. How to get this? 回答1: I'm not sure, if it's a good idea to do that for scatter plots in general (you have the same description for different data points, maybe just use some legend here?), but I guess a specific

Change combobox option to modificate graphic/chart

自闭症网瘾萝莉.ら 提交于 2021-02-17 05:16:21
问题 I'm using PyQt5 to build up a user interface to show up data from "curve_fit" method. As the data which I'm working can have discontinuities, my return from the method is divided on curve slices. My GUI is composed by two graphs and one combo box. The function of the combo box is to enable the user to choose which slice the chart will show. Although the event of the combo box is working, my charts still the same, without any modification. main.py import sys from PyQt5 import QtWidgets import

How to set default tick params in python/matplotlib?

让人想犯罪 __ 提交于 2021-02-17 05:12:37
问题 I would like all of my plots to have ticks that point inside rather than the matplotlib default of outside. So I am looking for a way to set this using plt.rcparams() For each plot, at the moment, I am doing: ax.tick_params(direction='out') But this only works for a single plot. Any idea how to set this with a default plot style at the top of the script or through plt.style.use()? 回答1: Reading the rcParams helps: plt.rcParams["xtick.direction"] = "out" plt.rcParams["ytick.direction"] = "out"

How to set default tick params in python/matplotlib?

不想你离开。 提交于 2021-02-17 05:08:56
问题 I would like all of my plots to have ticks that point inside rather than the matplotlib default of outside. So I am looking for a way to set this using plt.rcparams() For each plot, at the moment, I am doing: ax.tick_params(direction='out') But this only works for a single plot. Any idea how to set this with a default plot style at the top of the script or through plt.style.use()? 回答1: Reading the rcParams helps: plt.rcParams["xtick.direction"] = "out" plt.rcParams["ytick.direction"] = "out"

Python Pylab, how to alter the size of the label specifying the magnitude of the axes

99封情书 提交于 2021-02-17 02:09:03
问题 I am attempting to plot differential cross-sections of nuclear decays and so the magnitudes of the y-axis are around 10^-38 (m^2) pylab as default plots the axis as 0.0,0.2,0.4... etc and has a '1e-38' at the top of the y-axis. I need to increase the font size of just this little bit, I have tried adjusting the label size py.tick_params(axis='y', labelsize=20) but this only adjusts the labels 0.0,0.2,0.4.... Many thanks for all help 回答1: You can access the text object using the ax.yaxis.get

Python Pylab, how to alter the size of the label specifying the magnitude of the axes

最后都变了- 提交于 2021-02-17 02:08:12
问题 I am attempting to plot differential cross-sections of nuclear decays and so the magnitudes of the y-axis are around 10^-38 (m^2) pylab as default plots the axis as 0.0,0.2,0.4... etc and has a '1e-38' at the top of the y-axis. I need to increase the font size of just this little bit, I have tried adjusting the label size py.tick_params(axis='y', labelsize=20) but this only adjusts the labels 0.0,0.2,0.4.... Many thanks for all help 回答1: You can access the text object using the ax.yaxis.get

Python Pylab, how to alter the size of the label specifying the magnitude of the axes

做~自己de王妃 提交于 2021-02-17 02:07:02
问题 I am attempting to plot differential cross-sections of nuclear decays and so the magnitudes of the y-axis are around 10^-38 (m^2) pylab as default plots the axis as 0.0,0.2,0.4... etc and has a '1e-38' at the top of the y-axis. I need to increase the font size of just this little bit, I have tried adjusting the label size py.tick_params(axis='y', labelsize=20) but this only adjusts the labels 0.0,0.2,0.4.... Many thanks for all help 回答1: You can access the text object using the ax.yaxis.get

Python Pylab, how to alter the size of the label specifying the magnitude of the axes

懵懂的女人 提交于 2021-02-17 02:07:01
问题 I am attempting to plot differential cross-sections of nuclear decays and so the magnitudes of the y-axis are around 10^-38 (m^2) pylab as default plots the axis as 0.0,0.2,0.4... etc and has a '1e-38' at the top of the y-axis. I need to increase the font size of just this little bit, I have tried adjusting the label size py.tick_params(axis='y', labelsize=20) but this only adjusts the labels 0.0,0.2,0.4.... Many thanks for all help 回答1: You can access the text object using the ax.yaxis.get

Python数据分析-可视化“大佬”之Seaborn

安稳与你 提交于 2021-02-17 00:14:49
——如果有想关注 Java开发相关 的内容,可以转<font color=red> 我的博客 </font>详细观看—— Seaborn 既然有了matplotlib,那为啥还需要seaborn呢?其实seaborn是在matplotlib基础上进行封装,Seaborn就是让困难的东西更加简单。用Matplotlib最大的困难是其默认的各种参数,而Seaborn则完全避免了这一问题。seaborn是针对统计绘图的,一般来说,seaborn能满足数据分析90%的绘图需求,复杂的自定义图形,还是要Matplotlib。Seaborn旨在使可视化成为探索和理解数据的核心部分。其面向数据集的绘图功能对包含整个数据集的数据框和数组进行操作,并在内部执行必要的语义映射和统计聚合,以生成信息图。 5种主题风格 darkgrid whitegrid dark white ticks 统计分析绘制图——可视化统计关系 统计分析是了解数据集中的变量如何相互关联以及这些关系如何依赖于其他变量的过程。常见方法可视化统计关系: 散点图和线图 。 常用的三个函数如下: replot() scatterplot(kind="scatter";默认) lineplot(kind="line",默认) 常用的参数 * x,y,hue 数据集变量 变量名 * date 数据集 数据集名 * row,col

机器学习入门 【二】

微笑、不失礼 提交于 2021-02-16 23:34:47
常用库简介 Numpy 基础科学计算库 Scipy 强大的科学计算工具集 Pandas 数据分析的利器 Matplotlib 画出优美的图形 Scikit-learn 机器学习库 Numpy 【sklearn使用numpy数组形式的数据进行处理,所以需要把数据转换为numpy数组形式,其中的多维数组也是numpy的核心功能之一】 import numpy i = numpy.array([[520,13,14],[25,9,178]]) print("i: \n{}".format(i)) 给变量i复制为一个数组 i是一个典型的numpy数组 结果: sklearn需要使用 scipy 来对算法进行执行 sparse函数,用来 生成稀疏矩阵,而稀疏矩阵用来存储那些大部分数组为0的np数组 【常用】 sparse用法 : import numpy as np from scipy import sparse matrix = np.eye(6) #用eye函数生成一个6*6对角矩阵 #矩阵中对角线上的元素数值为1,其余都是0 sparse_matrix = sparse.csr_matrix(matrix) #这一行把np数组转化为CSR格式的scripy稀疏矩阵(sparse matrix) #sparse函数只会存储非0元素 print("对角矩阵:\n {}".format