腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
工具
TVP
最新优惠活动
文章/答案/技术大牛
搜索
搜索
关闭
发布
精选内容/技术社群/优惠产品,
尽在小程序
立即前往
首页
标签
ggplot2
#
ggplot2
关注
专栏文章
(395)
技术视频
(0)
互动问答
(9)
ggplot2 如何将双x轴显示在底部?
0
回答
ggplot2
R语言ggplot2 如何添加第二x轴?
0
回答
ggplot2
ggplot2我想要的就是将y轴向右移动,并将它们向左对齐,以将它们包含在条形图中?
0
回答
element
、
ggplot2
、
size
、
text
、
title
ggplot2如何单独设置拟合线条的图例?
0
回答
ggplot2
如何用ggplot2同时让图中标签文字的方向各不相同?
0
回答
ggplot2
请问如何用ggplot2使图表中的文字方向有的水平有的垂直有的45度?
0
回答
ggplot2
、
label
、
point
、
图表
在ggplot2中,如何添加额外的图例?
1
回答
ggplot2
、
map
、
地图
、
工作
、
数据
不不个了
路遙知馬力 日久見人心。
已采纳
我并不是100%确定这是你想要的,但是我知道这是我如何处理这个问题。如果我们将一些geom使用的数据映射到图上xx.sub1.df,但是使其在图上不可见,我们仍然可以得到一个图例。在这里我已经使用过geom_point,但你可以让它成为别人。代码: p <- ggplot(xx.sub2.df) + aes(long, lat, fill = (SID79/BIR79)*1000, group = group) + geom_polygon() + geom_path(color="grey80") + coord_equal() + scale_fill_gradientn(colours = brewer.pal(7, "YlOrBr")) + geom_polygon(data = xx.sub1.df, fill = "grey50") + geom_path(data = xx.sub1.df, color="grey80") + labs(fill = "Mapped value", title = "Title") #Now we add geom_point() setting shape as NA, but the colour as "grey50", so the #legend will be displaying the right colour p2 <- p + geom_point(data = xx.sub1.df, aes(size="xx.sub1", shape = NA), colour = "grey50") 📷 现在我们只需要改变图例上点的大小和形状,并更改图例的名称: p2 + guides(size=guide_legend("Source", override.aes=list(shape=15, size = 10))) 📷 当然,你可以更改标签的工作方式或其他方式来突出显示你想要展示的内容。 ...
展开详请
赞
0
收藏
0
评论
0
分享
我并不是100%确定这是你想要的,但是我知道这是我如何处理这个问题。如果我们将一些geom使用的数据映射到图上xx.sub1.df,但是使其在图上不可见,我们仍然可以得到一个图例。在这里我已经使用过geom_point,但你可以让它成为别人。代码: p <- ggplot(xx.sub2.df) + aes(long, lat, fill = (SID79/BIR79)*1000, group = group) + geom_polygon() + geom_path(color="grey80") + coord_equal() + scale_fill_gradientn(colours = brewer.pal(7, "YlOrBr")) + geom_polygon(data = xx.sub1.df, fill = "grey50") + geom_path(data = xx.sub1.df, color="grey80") + labs(fill = "Mapped value", title = "Title") #Now we add geom_point() setting shape as NA, but the colour as "grey50", so the #legend will be displaying the right colour p2 <- p + geom_point(data = xx.sub1.df, aes(size="xx.sub1", shape = NA), colour = "grey50") 📷 现在我们只需要改变图例上点的大小和形状,并更改图例的名称: p2 + guides(size=guide_legend("Source", override.aes=list(shape=15, size = 10))) 📷 当然,你可以更改标签的工作方式或其他方式来突出显示你想要展示的内容。
如何制作xkcd风格的图表?
2
回答
ggplot2
、
基础
、
解决方案
、
图表
、
系统
秋之夕颜清
念念不忘,必有回响
基本的画线功能: xkcd_line <- function(x, y, color) { len <- length(x); rg <- par("usr"); yjitter <- (rg[4] - rg[3]) / 1000; xjitter <- (rg[2] - rg[1]) / 1000; x_mod <- x + rnorm(len) * xjitter; y_mod <- y + rnorm(len) * yjitter; lines(x_mod, y_mod, col='white', lwd=10); lines(x_mod, y_mod, col=color, lwd=5); } 基本轴: xkcd_axis <- function() { rg <- par("usr"); yaxis <- 1:100 / 100 * (rg[4] - rg[3]) + rg[3]; xaxis <- 1:100 / 100 * (rg[2] - rg[1]) + rg[1]; xkcd_line(1:100 * 0 + rg[1] + (rg[2]-rg[1])/100, yaxis,'black') xkcd_line(xaxis, 1:100 * 0 + rg[3] + (rg[4]-rg[3])/100, 'black') } 和示例代码: data <- data.frame(x=1:100) data$one <- exp(-((data$x - 50)/10)^2) data$two <- sin(data$x/10) plot.new() plot.window( c(min(data$x),max(data$x)), c(min(c(data$one,data$two)),max(c(data$one,data$two)))) xkcd_axis() xkcd_line(data$x, data$one, 'red') xkcd_line(data$x, data$two, 'blue')...
展开详请
赞
0
收藏
0
评论
0
分享
基本的画线功能: xkcd_line <- function(x, y, color) { len <- length(x); rg <- par("usr"); yjitter <- (rg[4] - rg[3]) / 1000; xjitter <- (rg[2] - rg[1]) / 1000; x_mod <- x + rnorm(len) * xjitter; y_mod <- y + rnorm(len) * yjitter; lines(x_mod, y_mod, col='white', lwd=10); lines(x_mod, y_mod, col=color, lwd=5); } 基本轴: xkcd_axis <- function() { rg <- par("usr"); yaxis <- 1:100 / 100 * (rg[4] - rg[3]) + rg[3]; xaxis <- 1:100 / 100 * (rg[2] - rg[1]) + rg[1]; xkcd_line(1:100 * 0 + rg[1] + (rg[2]-rg[1])/100, yaxis,'black') xkcd_line(xaxis, 1:100 * 0 + rg[3] + (rg[4]-rg[3])/100, 'black') } 和示例代码: data <- data.frame(x=1:100) data$one <- exp(-((data$x - 50)/10)^2) data$two <- sin(data$x/10) plot.new() plot.window( c(min(data$x),max(data$x)), c(min(c(data$one,data$two)),max(c(data$one,data$two)))) xkcd_axis() xkcd_line(data$x, data$one, 'red') xkcd_line(data$x, data$two, 'blue')
在ggplot2中如何旋转和放置轴标签?
2
回答
ggplot2
、
可视化
秋之夕颜清
念念不忘,必有回响
要使刻度标签上的文本完全可见并以与y轴标签相同的方向读取,请将最后一行更改为
代码语言:
txt
复制
q + theme(axis.text.x=element_text(angle=90, hjust=1))
赞
0
收藏
0
评论
0
分享
要使刻度标签上的文本完全可见并以与y轴标签相同的方向读取,请将最后一行更改为 q + theme(axis.text.x=element_text(angle=90, hjust=1))
热门
专栏
量化投资与机器学习
736 文章
437 订阅
生信宝典
739 文章
339 订阅
生信技能树
2.2K 文章
1.2K 订阅
深度学习之tensorflow实战篇
603 文章
84 订阅
数据小魔方
470 文章
145 订阅
领券