图源于电力电子课本65页——电容滤波的单相不可控整流电路。

f<-function(w,d)
{
l<-w/sqrt(w^2+1)*exp(-atan(w)/w)*exp(-d/w)
r<-sin(d)
return(l-r)
}
w<-seq(0.01,60,0.01)
d<-rep(0,length(w))
s<-rep(0,length(w))
for(i in 1:length(w))
{
root<-uniroot(f,c(0,pi/2),w=w[i],tol=0.01)
d[i]<-root$root
s[i]<-pi-d[i]-atan(w[i])
} library(ggplot2)
DataSet1<-data.frame(w,value=d,lab=rep("d",length(w)))
DataSet2<-data.frame(w,value=s,lab=rep("s",length(w)))
DataSet <- rbind(DataSet1,DataSet2) p<-ggplot(data=DataSet,aes(w,value,color=lab))
p+geom_line()+
scale_colour_hue("value",breaks=c("d","s"),labels=c(expression(delta),expression(theta)))+
labs(x=(expression(omega*RC/rad)),y=expression(list(delta,theta)/rad))+
xlim(0,60)+ylim(0,pi)+
scale_x_continuous(expand = c(0,0))+
scale_y_continuous(breaks=round(c(0,pi/6,pi/3,pi/2,2*pi/3,5*pi/6,pi),digits=2),
labels=expression(0,pi/6,pi/3,pi/2,2*pi/3,5*pi/6,pi),expand = c(0, 0))

练习了:

  1. 自定义离散色彩标度;
  2. 修改坐标轴标签;
  3. 修改坐标范围;
  4. 修改显示刻度;
  5. expression数学表达式。

更新补充:图源于电力电子课本143页——单相交流调压电路。

AngleToRadian<-function(alpha)
{
return(alpha*pi/180)
}
RadianToAngle<-function(alpha)
{
return(alpha/pi*180)
}
f<-function(alpha,theta,varphi)
{
var1<-sin(alpha+theta-varphi)
if(varphi==0)
var2<-0
else
var2<-sin(alpha-varphi)*exp(-theta/tan(varphi))
return(var1-var2)
}
alpha<-seq(0,180-2,0.5)
varphi<-seq(0,90,15)
data<-data.frame() for(a in alpha)
{
for(v in varphi)
{
if(v<=a){
t=uniroot(f,c(1e-3,pi+1e-3),alpha=AngleToRadian(a),
varphi=AngleToRadian(v),tol=0.001)
result<-c(a,RadianToAngle(t$root),v)
data<-rbind(data,result)}
}
}
names(data)<-c("alpha","theta","varphi") data$I_VTN<-rep(0,dim(data)[1])
for(i in 1:dim(data)[1])
{
a<-AngleToRadian(data$alpha[i])
t<-AngleToRadian(data$theta[i])
if(data$varphi[i]==90)
v<-AngleToRadian(data$varphi[i]-1)
else
v<-AngleToRadian(data$varphi[i]) data$I_VTN[i]<-1/(2*sqrt(pi))*sqrt(t-sin(t)*cos(2*a+v+t)/cos(v))
}
library(ggplot2)
theme_set(theme_light())
ggplot(data=data,aes(alpha,theta,color=factor(varphi)))+
geom_line()+scale_colour_hue(expression(varphi/(degree)))+
labs(x=(expression(alpha/(degree))),y=expression(theta/(degree)))
ggplot(data=data,aes(alpha,I_VTN,color=factor(varphi)))+geom_line()+
geom_line()+scale_colour_hue(expression(varphi/(degree)))+
labs(x=(expression(alpha/(degree))),y=expression(I[VTN]))

ggplot2练习的更多相关文章

  1. 跟我一起ggplot2(1)

    ggplot2 R的作图工具包,可以使用非常简单的语句实现非常复杂漂亮的效果. qplot 加载qplot library(ggplot2) # 测试数据集,ggplot2内置的钻石数据 qplot( ...

  2. R语言:ggplot2精细化绘图——以实用商业化图表绘图为例

    本文版权归http://www.cnblogs.com/weibaar 本文旨在介绍R语言中ggplot2包的一些精细化操作,主要适用于对R画图有一定了解,需要更精细化作图的人,尤其是那些刚从exce ...

  3. ggplot2 多图排版

    和R自带的绘图系统不同,ggplot2不能直接通过par(mfrow) 或者 layout()来排版多张图片.终于发现,其实可以通过一个『gridExtra』包来搞定: require(gridExt ...

  4. ggplot2 上篇

    title: "ggplot2 上篇" author: "li_volleyball" date: "2016年4月16日" output: ...

  5. ggplot2包--R可视化

    1.ggplot2发展历程 ggplot2是Hadley在爱荷华州立大学博士期间的作品,也是他博士论文的主题之一,实际上ggplot2还有个前身ggplot,但后来废弃了,某种程度上这也是Hadley ...

  6. ggplot2.multiplot:将多个图形使用GGPLOT2在同一页上

    一页多图 介绍 ggplot2.multiplot是一个易于使用的功能,将多个图形在同一页面上使用R统计软件和GGPLOT2绘图方法.这个功能是从easyGgplot2包. 安装并加载easyGgpl ...

  7. ggplot2 legend图例的修改

    ggplot2中的legend包括四个部分: legend.tittle, legend.text, legend.key, legend.backgroud.针对每一部分有四种处理方式: eleme ...

  8. Plotting means and error bars (ggplot2)

    library(ggplot2) ############################################# # summarySE ######################### ...

  9. ggplot2 学习笔记 (持续更新.....)

    1. 目前有四种主题 theme_gray(), theme_bw() , theme_minimal(),theme_classic() 2. X轴设置刻度 scale_x_continuous(l ...

  10. ggplot2 demo

    title <- rep("A Really Rather Long Text Label", 25)value <- runif(25, 1,10)spacing & ...

随机推荐

  1. mvn docker 部署 每次都需要下载包的问题

    项目大版本更新依赖很稳定,小版本基本不引入其他依赖 docker打包时image时,一次mvn package后 把m2文件拷贝解压,之后build时直接拷入,省得还得下载 FROM maven:3. ...

  2. 牛客-小w的a=b问题

    题目传送门 sol1:老实做,预处理出所有2到1e5的素数,对所有数进行分解质因数,然后对比因子个数.感觉有点卡常,用了快读然后多次优化之后才过的,map也用上了. 素数筛,快速分解质因数 #incl ...

  3. [LC] 359. Logger Rate Limiter

    Design a logger system that receive stream of messages along with its timestamps, each message shoul ...

  4. C++对数组进行复制

    C++ 风格的复制操作 使用STL中的copy算法 int a[] = {1,2,3,4,5}; int b[5]; std::copy(std::begin(a),std::end(a),std:: ...

  5. t-检验

    https://wenku.baidu.com/view/3954f9d9a58da0116c17497b.html介绍的挺好的,可以查看~ 应用方面:用于推断差异发生的概率,与f检验,卡方检验并列 ...

  6. bubble chart|Matrix Scatter|Overlay Scatter|Scatterplots|drop-line|box plot|Stem-and-leaf plot|Histogram|Bar chart|Pareto chart|Pie chart|doughnut chart|

    应用统计学 对类别数据要分类处理: Bar chart复式条形图便于对比: Pareto chart:对类别变量依据频数高低排列: Pie chart:饼图用于一个样本,可以区分类别数据 doughn ...

  7. 整数拆分-dp问题

    Integer Partition In number theory and combinatorics, a partition of a positive integer n, also call ...

  8. response 画验证码

    代码 import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.awt.image.Bu ...

  9. Apache虚拟机的配置文件解说

    1.为了方便管理虚拟主机,我决定使用一种方法,那就是修改httpd-vhosts.conf文件. 第一步首先要使扩展文件httpd-vhosts.conf生效: 1. 打开 apache/conf/h ...

  10. python——实现三级菜单选择的功能(原创)

    #coding:utf-8 dict={'beijing':{'haidingqu':['qinghe','keji'],'chaoyangqu':['q','w']},'shandong':{'li ...