axis

how to change x-axis limits ggplot2 r

陌路散爱 提交于 2019-12-02 22:33:56
问题 I would like to set limit for x-axis using ggplot bar plot. The whole plot is ok, but when I use ylim(1,6) (these are limits what I need) the bars disappear. Data: var.A <- as.numeric(c(1:13)) var.B <- c(4.351833, 2.938000, 4.726465, 3.747162, 3.720737, 4.297117, 4.304500, 4.061277, 4.595236, 4.105444, 3.701684, 3.523563, 4.170000) df <- data.frame(var.A,var.B) Ggplot code: ggplot(df, aes(x=factor(var.A), y=var.B)) + geom_bar(position=position_dodge(), stat="identity", fill="#fff68f", colour=

python学习之删除DataFrame某一行/列内容

匿名 (未验证) 提交于 2019-12-02 22:11:45
用法:DataFrame.drop(labels=None,axis=0, index=None, columns=None, inplace=False) 参数说明: labels 就是要删除的行列的名字,用列表给定 axis 默认为0,指删除行,因此删除columns时要指定axis=1; index 直接指定要删除的行 columns 直接指定要删除的列 inplace=False,默认该删除操作不改变原数据,而是返回一个执行删除操作后的新dataframe; inplace=True,则会直接在原数据上进行删除操作,删除后无法返回。 因此,删除行列有两种方式: 1)labels=None,axis=0 的组合 2)index或columns直接指定要删除的行或列 >>>df = pd.DataFrame(np.arange(12).reshape(3,4), columns=['A', 'B', 'C', 'D']) >>>df A B C D 0 0 1 2 3 1 4 5 6 7 2 8 9 10 11 #Drop columns,两种方法等价 >>>df.drop(['B', 'C'], axis=1) A D 0 0 3 1 4 7 2 8 11 >>>df.drop(columns=['B', 'C']) A D 0 0 3 1 4 7 2 8 11 #

NumPy 学习笔记(四)

匿名 (未验证) 提交于 2019-12-02 22:11:45
NumPy 算术函数:    1、 numpy.reciprocal(arr) 返回参数逐个元素的 倒数   2、 numpy.power(one, two) 幂 ,即 one^two   3、 numpy.mod(x1, x2) 计算输入数组中相应元素的 余数 ,函数 numpy.remainder(x1, x2) 也产生相同的结果 import numpy as np arr = np.array([[1., 2., 3.], [4., 5., 6.], [7., 8., 9.]]) print("reciprocal arr: ", np.reciprocal(arr)) print("power by 2: ", np.power(arr, 2)) print("mod by arr.T: ", np.mod(arr, arr.T)) print("remainder by arr.T: ", np.remainder(arr, arr.T)) NumPy 统计函数:   1、 numpy. amax (a, axis=None, out=None, keepdims=<no value>, initial=<no value>) max (a, axis=None, out=None, keepdims=<no value>, initial=<no value>)

Numpy array 合并

匿名 (未验证) 提交于 2019-12-02 22:11:45
1、np.vstack() :垂直合并 >>> import numpy as np >>> A = np.array([1,1,1]) >>> B = np.array([2,2,2]) >>> print(np.vstack((A,B))) # vertical stack,属于一种上下合并,即对括号中的两个整体进行对应操作 [[1 1 1] [2 2 2]] >>> C = np.vstack((A,B)) >>> print(A.shape,C.shape) (3,) (2, 3) 2、np.hstack():水平合并 >>> D = np.hstack((A,B)) # horizontal stack,即左右合并 >>> print(D) [1 1 1 2 2 2] >>> print(A.shape,D.shape) (3,) (6,) 3、np.newaxis():转置 >>> print(A[np.newaxis,:]) [[1 1 1]] >>> print(A[np.newaxis,:].shape) (1, 3) >>> print(A[:,np.newaxis]) [[1] [1] [1]] >>> print(A[:,np.newaxis].shape) (3, 1) >>> A = np.array([1,1,1])[:,np.newaxis] >>>

【转】Pandas学习笔记(五)合并 concat

醉酒当歌 提交于 2019-12-02 22:01:20
原文:https://morvanzhou.github.io/tutorials/data-manipulation/np-pd/3-6-pd-concat/ 本文有删改 Concat pandas 处理多组数据的时候往往会要用到数据的合并处理,使用 concat 是一种基本的合并方式.而且 concat 中有很多参数可以调整,合并成你想要的数据形式. axis (合并方向) axis=0是预设值,因此未设定任何参数时,函数默认axis=0。 import pandas as pd import numpy as np #定义资料集 df1 = pd.DataFrame(np.ones((3,4))*0, columns=['a','b','c','d']) df2 = pd.DataFrame(np.ones((3,4))*1, columns=['a','b','c','d']) df3 = pd.DataFrame(np.ones((3,4))*2, columns=['a','b','c','d']) #concat纵向合并 res = pd.concat([df1, df2, df3], axis=0) #打印结果 print(res) """ a b c d 0 0.0 0.0 0.0 0.0 1 0.0 0.0 0.0 0.0 2 0.0 0.0 0.0 0.0 0

Eclipse中开发webservice

烈酒焚心 提交于 2019-12-02 21:27:14
eclipse开发webservie 1.下载axis2相关架包----war,bin是必须的; axis2的eclipse插件(2个)-http://apache.dataguru.cn/axis/axis2/java/core/ org.apache.axis2.eclipse.codegen.plugin_0.0.0.SNAPSHOT.jar org.apache.axis2.eclipse.service.plugin_0.0.0.SNAPSHOT.jar 2.安装eclipse的axis2插件 将a中的两个jar文件放入eclipse路径下面的plugins文件夹下面,重启eclipse即可。 成功标志-----new,出现Axis2 Wizards选项。 3.在eclipse中配置axis2的运行环境 Windows---->preferences---->Web Service---->Axis2 Preferences,选中Axis2 Runtime将a中下载的 war(事先解压)路径选中即可。 4.编写服务器上面的web项目,然后创建webservice 注意: Service implementation: 需要提供出来的类----web项目的src目录下面 Web service runtime: Apache Axis2 创建完毕之后,在地址栏中输入

Displaying minor logarithmic ticks in x-axis in R

血红的双手。 提交于 2019-12-02 20:50:58
I have a normal distribution plot and a histogram plot with x axis in log scale displaying 0, 10^0, 10^1 ... I want to include minor ticks between the major ones. Actually I was able to change the major ticks format from 1, 2, 3 and so on to 10^0, 10^1, 10^2, 10^3 using the solution given to me in my previous question . I used the following code for the major ticks : major.ticks <- axTicks(1) labels <- sapply(major.ticks,function(i) as.expression(bquote(10^ .(i))) ) axis(1,at=major.ticks,labels=labels) Can this be edited to just mark the minor ticks without labeling them? There is a function

数学和统计方法.m

非 Y 不嫁゛ 提交于 2019-12-02 20:14:55
介绍几个基础数组统计方法: 1、 sum():沿着轴向计算所有原色的累和,0长度的数组累和为0 import numpy as np arr = np.array([[3,3],[1,9],[4,8]]) print(arr) print(arr.mean(1))# axis=1的时候行平均值 0的时候计算列平均值(书本112页有错误) 结果 [[3 3] [1 9] [4 8]] -------- [3. 5. 6.] 2、mean():求数学平均,0长度的数组平均值为NaN print(arr.sum(1)) #axis=1的时候行和 0 的时候计算列和 print('--------') 结果 [3. 5. 6.] 3、cumsum():从0 开始元素累积和 arr1 = np.array([0,1,2,3,4,5,6,7,8]) print(arr1.cumsum()) 结果 [ 0 1 3 6 10 15 21 28 36] #结果解析:从0开始加,一开始的值就是0,0开始加第一个数,0+0=0,上一个结果拿来继续加数组第二个数字 0+1=1 ,1+2=3, 3+3=6。。。。。。以此类推 4、cumprod():从1开始元素累积积 arr2 = np.array([[0,1,2],[3,4,5],[6,7,8]]) print(arr2) print('--------

机器学习--支持向量机 (SVM)算法的原理及优缺点

我只是一个虾纸丫 提交于 2019-12-02 19:51:29
一、支持向量机 (SVM)算法的原理    支持向量机(Support Vector Machine,常简称为SVM)是一种监督式学习的方法,可广泛地应用于统计分类以及回归分析。它是将向量映射到一个更高维的空间里,在这个空间里建立有一个最大间隔超平面。在分开数据的超平面的两边建有两个互相平行的超平面,分隔超平面使两个平行超平面的距离最大化。假定平行超平面间的距离或差距越大,分类器的总误差越小。      对于线性可分的支持向量机求解问题实际上可转化为一个带约束条件的最优化求解问题:     推理过程:                          结果:         对于线性不可分的支持向量机求解问题实际上可转化为一个带约束条件的soft-margin最优化求解问题:      二、代码实现 import numpy as np import matplotlib.pyplot as plt from sklearn import datasets from sklearn.preprocessing import StandardScaler from sklearn.svm import LinearSVC iris = datasets.load_iris() X = iris.data y = iris.target X = X[y<2,:2] y = y[y<2]

以np.concatenate为主题,谈谈numpy数组按维度合并的问题

一个人想着一个人 提交于 2019-12-02 19:03:05
1.引言 最近在做多模态融合的图像问题,其中最需要解决的就是不同模态的图像用什么方法进行融合,最简单也最直观的方法就是采用合并数组的方法,将不同模态的图像合并为多通道进行处理。在一些论文中,比如《Deep Learning-Based Image Segmentation on Multimodal Medical Imaging》中,如图1.1所示,论文中发现简单的concat 成多通道进行处理反而会比经过一部分网络提取特征后再融合效果更好。不过不同的情况需要具体分析,在《 FusionNet: Incorporating Shape and Texture for Abnormality Detection in 3D Abdominal CT Scans 》中,文章进行了多种组合的实验(不是模态融合,而是图片和mask的组合),结果发现某一种组合的效果最好。 图1.1 文章中提到的融合网络结构以及效果 不过总的来说,能够使用concat进行合并数组肯定是快速而有效的一种模态融合方法。 2.简要解析np.concatente官方文档 参见 https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.concatenate.html numpy. concatenate ( (a1 , a2 , ...) ,