axes

Embedding small plots inside subplots in matplotlib

﹥>﹥吖頭↗ 提交于 2019-12-17 02:28:52
问题 If you want to insert a small plot inside a bigger one you can use Axes, like here. The problem is that I don't know how to do the same inside a subplot. I have several subplots and I would like to plot a small plot inside each subplot. The example code would be something like this: import numpy as np import matplotlib.pyplot as plt fig = plt.figure() for i in range(4): ax = fig.add_subplot(2,2,i) ax.plot(np.arange(11),np.arange(11),'b') #b = ax.axes([0.7,0.7,0.2,0.2]) #it gives an error,

Seaborn入门系列(二)——barplot&countplot&pointplot

北城余情 提交于 2019-12-17 02:13:50
微信公众号:易执 如有问题或建议,请公众号留言 Seaborn是基于matplotlib的Python可视化库。 它提供了一个高级界面来绘制有吸引力的统计图形。Seaborn其实是在matplotlib的基础上进行了更高级的API封装,从而使得作图更加容易,不需要 经过大量的调整就能使你的图变得精致。 注:所有代码均在IPython notebook中实现 barplot(条形图) 条形图表示数值变量与每个矩形高度的中心趋势的估计值,并使用误差线提供关于该估计值附近的不确定性的一些指示。具体用法如下: seaborn.barplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None, estimator=(function mean), ci=95, n_boot=1000, units=None, orient=None, color=None, palette=None, saturation=0.75, errcolor='.26', errwidth=None, capsize=None, dodge=True, ax=None, **kwargs) 接下来还是通过具体例子学习里面的一些参数的用法: %matplotlib inline import pandas as pd import

matplotlib中使用Event编码的学习步骤

点点圈 提交于 2019-12-16 19:32:45
第一步: https://matplotlib.org/tutorials/introductory/usage.html#sphx-glr-tutorials-introductory-usage-py 看这个了解大概的matplotlib使用的背景框架:基于函数编程与基于对象编程的区别: Figure, Axes, Axis, Tick,Canvas之间的关系是什么? Backend主要包含的FigureCanvas 与 Renderer分别可以表现为画布和画笔,而Artist就是实现画笔与画布之间连接的桥梁? 理解什么是交互式,什么是非交互式,如何将screen置于前段进行显示? 第二步: https://matplotlib.org/2.0.0/users/artists.html#object-containers 了解各个Artist之间如何实现互相引用,他们的Property有哪些?如何用get与set函数调用查看这些Property。 以及Container Artist主要包含的attributes有哪些? 对于figure 来说: fig.axes, fig.images; fig.lines, fig.texts, fig,legends 都是在一个list里面,fig.axes是一个包含container的list,其他的都是primitive的list

特征数据清洗 编码 标准化

▼魔方 西西 提交于 2019-12-13 16:49:15
特征工程是机器学习的第一步,涉及清理现有数据集、提高信噪比和降低维数的所有技术。大多数算法对输入数据有很强的假设,当使用原始数据集时,它们的性能可能会受到负面影响。 另外有些特征之间高度相关,在其中一个特征提供了足够的信息之后,与之相关的其他特征往往无法提供额外的信息。这时我们就需要了解如何减少特征数量或者仅选择最佳特征。 一、scikit-learn数据集 scikit-learn提供了一些用于测试的内置数据集,这些数据集包含在sklearn.datasets中,每个数据集都包含了输入集(特征集)X和标签(目标值)y。比如波士顿房价的数据集(用于回归问题): from sklearn.datasets import load_boston boston = load_boston() X = boston.data y = boston.target print(‘特征集的shape:’, X.shape) print(‘目标集的shape:’, y.shape) 特征集的shape: (506, 13) 目标集的shape: (506,) 可以看到,这个数据集包含了506个样本、13个特征,以及1个目标值。 假如我们不想使用scikit-learn提供的数据集,那么我们还可以使用scikit-learn提供的工具来手动创建特定的数据集。相关的方法有: make

ggplot2 annotation_ticks on the outside of the plot region

梦想的初衷 提交于 2019-12-13 16:15:16
问题 I try to find an elegant way to insert minor ticks on plots created with ggplot2 . I found a function which does almost exactly what I want: https://rdrr.io/github/hrbrmstr/ggalt/src/R/annotation_ticks.r There is only one drawback: the ticks, like in annotation_logticks , are drawn inside the plot region. I need them to be on the outside. A solution could be to use negative values for the tick-length. When I do so, the ticks disappear. I assume, that this is due to the default clipping action

Matlab GUI axes extract position from datacursor

自闭症网瘾萝莉.ら 提交于 2019-12-13 08:03:27
问题 hope anyone can help me. I try to load and display a image in my GUI. After that i activate datacursormode. Now I want to extract the position from my datacursor object and save the informations into a global variable to work on this data. Here is my code: function varargout = myGui(varargin) % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @myGui_OpeningFcn, ... 'gui_OutputFcn',

d3 unevenly distributed scaling

こ雲淡風輕ζ 提交于 2019-12-12 18:03:40
问题 any suggestions for drawing axes with unequal spacing between the values. For instance I am currently drawing axes using: yScale = d3.scale.linear().domain([0, 60000]).range([height, 0]) I need more spacing between 0 and 5000 than distributing all the data points equally 回答1: Try using a polylinear scale: yScale = d3.scale.linear().domain([0, 5000, 60000]).range([height, height/2, 0]) The range (0, 5000) and (5000, 60000) will both be given the same amount of space. 来源: https://stackoverflow

Python pandas plotting shift x-axis if twinx two y-axes

冷暖自知 提交于 2019-12-12 16:37:25
问题 I have a dataframe with 3 columns: one of them is a "groupby" column, the other two are "normal" columns with values. I want to generate a boxplot and a bar chart as well. On the bar chart I want to visualize the number of occurences of each group's element. Let my sample code tell this dataframe in more detailed: li_str = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'] df = pd.DataFrame([[i]+j[k] for i,j in {li_str[i]:np.random.randn(j, 2).tolist() for i,j in

Force the origin to start at 0

筅森魡賤 提交于 2019-12-12 05:45:16
问题 How can I set the origin / interception of the y-axis and x-axis in ggplot2? The line of the x-axis should be exactly at y=Z . With Z=0 or another given value. 回答1: xlim and ylim don't cut it here. You need to use expand_limits , scale_x_continuous , and scale_y_continuous . Try: df <- data.frame(x = 1:5, y = 1:5) p <- ggplot(df, aes(x, y)) + geom_point() p <- p + expand_limits(x = 0, y = 0) p # not what you are looking for p + scale_x_continuous(expand = c(0, 0)) + scale_y_continuous(expand

Axis numerical offset in matplotlib

余生颓废 提交于 2019-12-12 04:26:00
问题 I'm plotting something with matplotlib and it looks like this: I can't seem to figure out why the x-axis is offset like it is...It looks like it's saying, 'whatever you read from me, add 2.398e9 to it for the actual x value'. This is not quite what I want...Can I make it take only the first 4 digits, instead? This is representing frequency, so I'd like to see something that reads: 2000 or 2400 or 2800....I can add the 'MHz' part in the axis title...But, this is unreadable at a glance. Is this