axis

How to keep axis labels in one side and axis title in another using ggplot2

微笑、不失礼 提交于 2020-01-14 14:00:07
问题 I wonder if it is possible (I know it is) to keep the plot's axis labels in one side of the plot and the plot's axis title in the opposite side, specifically in a discrete geom_tile() plot as follows: 回答1: You can use sec.axis = dup_axis() inside scale_x_*() to duplicate both axis then remove what you don't need inside theme() . ggplot(mtcars, aes(x=mpg, y=hp)) + geom_point() + labs(title="mpg vs hp") + scale_y_continuous(position = 'right', sec.axis = dup_axis()) + #remember to check this

Python练习系列

北城以北 提交于 2020-01-14 12:17:46
Python标准库 Numpy教程 Tensorflow API 目录 一. yield: 二. tf.constant: 三. tf.stack 和 tf.unstack: 四. tf.tensordot: 五. 对多个相同维度的类数组同时打乱顺序,但是保持它们之间的一一对应关系: 六. 获取当前所打开文件的路径os.path.dirname(os.path.realpath(sys.argv[0])): 七. 修改文件夹下所有文件的名字的简单示例os.rename: 八. python 执行某段程序,因不知名原因而一直卡顿着也不报错退出,可以设置超时,跳过这部分的执行。func_timeout.func_set_timeout(1, False) 九. 在代码编写中查看某一库的版本: 十. signal.argrelextrema寻找局部极大、小值: 一. yield: 在一个函数中,当一个循环的结果经过 yield ,那么,这个函数就不再是普通的函数,它成为了一个 generator(生成器) 函数,返回的结果是生成器,那么,你就可以通过 s.__next__() 或者 next(s) (s是调用函数返回值)方法获得每一次迭代的值。这样做的好处是节省内存。 比如下面的代码,每调用一次 __next__() ,就会执行yield之前的代码,直到yield,就会挂起

数据分析:numpy学习总结

天涯浪子 提交于 2020-01-13 08:45:05
numpy中轴的概念 轴的概念 : 在numpy中可以理解为方向,使用0,1,2…数字表示, 对于一个一维数组,只有一个0轴,对于二维数组(shape(2, 2)), 有0轴和1轴,对于三维数组(shape(2, 2, 3)),有0,1,2轴(分别对应数组的(“块”,“行”, “列”)) 二维数组的轴 三维数组的轴: numpy读取数据 import numpy as np "" " numpy读取数据: np.loadtxt(frame, dtype=np.float, delimiter=None, skiprows=0, usecols=None,unpack=False) 参数: frame: 文件、字符串或产生器,可以是.gz或bz2压缩文件 dtype:数据类型,可选,CSV的字符串以什么数据类型读入数组中,默认np.float delimiter: 分隔字符串,默认是任何空格 skiprows: 跳过前x行,一般跳过第一行表头 usecols: 读取指定的列,索引,元组类型 unpack:如果True,则转置,读入属性将分别写入不同数组变量,False读入数据值写入一个数组变量,默认为False 说明: np.loadtxt(filepath_csv, delimiter=" , ", dtype=int, unpack=True)

3_特征工程

六眼飞鱼酱① 提交于 2020-01-13 00:56:19
任务3 特征工程&特征选择(3天) 特征工程 #核心代码举例 # 统计特征 #计算均值 gp = train . groupby ( by ) [ fea ] . mean ( ) #计算中位数 gp = train . groupby ( by ) [ fea ] . median ( ) #计算方差 gp = train . groupby ( by ) [ fea ] . std ( ) #计算最大值 gp = train . groupby ( by ) [ fea ] . max ( ) #计算最小值 gp = train . groupby ( by ) [ fea ] . min ( ) #计算出现次数 gp = train . groupby ( by ) [ fea ] . size ( ) # groupby生成统计特征:mean,std # 按照communityName分组计算面积的均值和方差 temp = data . groupby ( 'communityName' ) [ 'area' ] . agg ( { 'com_area_mean' : 'mean' , 'com_area_std' : 'std' } ) # 特征拆分 # 将houseType转为'Room','Hall','Bath' def Room ( x ) : Room =

Batch Normalization、Layer Normalization、Instance Normalization、Group Normalization、Switchable Normalization比较

£可爱£侵袭症+ 提交于 2020-01-12 19:25:07
深度神经网络难训练一个重要的原因就是深度神经网络涉及很多层的叠加,每一层的参数变化都会导致下一层输入数据分布的变化,随着层数的增加,高层输入数据分布变化会非常剧烈,这就使得高层需要不断适应低层的参数更新。为了训练好模型,我们需要谨慎初始化网络权重,调整学习率等。 本篇博客总结几种归一化办法,并给出相应计算公式和代码。 归一化层,目前主要有这几个方法, Batch Normalization (2015年)、 Layer Normalization (2016年)、 Instance Normalization (2017年)、 Group Normalization (2018年)、 Switchable Normalization (2018年); 将输入的图像shape记为[ N , C hannel, H eight, W idth],这几个方法主要的区别就是在, batch Norm :在batch上,对NHW做归一化,对小batchsize效果不好; layer Norm :在通道方向上,对CHW归一化,主要对RNN作用明显; instance Norm :在图像像素上,对HW做归一化,用在风格化迁移; Group Norm :将channel分组,然后再做归一化; Switchable Norm :将BN、LN、IN结合,赋予权重

pandas-python基础操作

白昼怎懂夜的黑 提交于 2020-01-12 15:57:25
import numpy as npimport pandas as pdindex = pd.date_range('1/1/2000',periods=8)s = pd.Series(np.random.randn(5),index = ['a','b','c','d','e'])df = pd.DataFrame(np.random.randn(8,3),index = index,columns=['A','B','C'])# -------------------------------------------------------------------------# 目录:# 属性和底层数据# 加速操作# 广播操作-加减乘除# 缺失值与填充缺失值# 比较操作# 布尔简化----> df和Series的对比# 描述性他统计 ----> 求和等函数# 最大值与最小值对应的索引-离散化与分位数# 函数应用# 重置索引与更换标签-align--填充# 迭代 for i in object# .dt 访问器 -访问时间的工具# 排序# -------------------------------------------------------------------------# -----------------------------------------------

Displaying minor logarithmic ticks in x-axis in R

谁说我不能喝 提交于 2020-01-11 18:50:07
问题 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

Displaying minor logarithmic ticks in x-axis in R

做~自己de王妃 提交于 2020-01-11 18:49:13
问题 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

Changing axis label color in LightningChart JS

五迷三道 提交于 2020-01-11 11:26:24
问题 The chart appears with dark background, axis numeric labels in grid positions are yellow. How do I change axis label colors to white? E.g. in this example https://www.arction.com/lightningchart-js-interactive-examples/#edit/lcjs_example_0001_simpleScatter I'm trying chart.getDefaultAxisX() .setInterval(0, 92 * dataFrequency) .setTickStyle((visibleTicks) => visibleTicks .setLabelFillStyle( color: ColorRGBA(255, 255, 255) }) ) But it's giving SyntaxError: Unexpected token, expected "," 回答1: