为什么我们应该URL编码?(Why we should URL encoding?)
只能使用ASCII字符集通过Internet发送URL。 由于URL通常包含ASCII集之外的字符,因此必须将URL转换为有效的ASCII格式。
为什么URL包含唯一的ASCII集,为什么URL应该编码?
URLs can only be sent over the Internet using the ASCII character-set. Since URLs often contain characters outside the ASCII set, the URL has to be converted into a valid ASCII format.
Why URLs contain the only ASCII set, Why URLs should be encoded ?
原文:
最满意答案
对于这些类型的问题,我更喜欢将轴绘制为单独的图,然后组合。 它需要一些摆弄,但允许您绘制几乎任何你想要的轴。
在我的解决方案中,我正在使用cowplot包中的函数
get_legend()
,align_plots()
和plot_grid()
。 免责声明:我是包裹作者。library(ggplot2) library(cowplot); theme_set(theme_gray()) # undo cowplot theme setting library(ggrepel) df<-data.frame() for (i in 1:50){ tmp_df <- data.frame(cell=paste0("cell", i), gene=paste0("gene", 1:100), exp=rnorm(100), ident=i%%5) df<-rbind(df, tmp_df) } labelRow <- rep("", 100) genes <- c(2, 5, 7, 11, 19, 23) labelRow[genes] <- paste0("gene ", genes) # make the heatmap plot heatmap <- ggplot(data = df, mapping = aes(x = cell,y = gene, fill = exp)) + geom_tile() + scale_fill_gradient2(name = "Expression") + scale_x_discrete(expand = c(0, 0), drop = TRUE) + facet_grid(facets = ~ident, drop = TRUE, space = "free", scales = "free", switch = "x") + theme(axis.line = element_blank(), axis.title = element_blank(), axis.text = element_blank(), axis.ticks = element_blank(), strip.text.x = element_text(angle = -90), legend.justification = "left", plot.margin = margin(5.5, 0, 5.5, 5.5, "pt")) # make the axis plot axis <- ggplot(data.frame(y = 1:100, gene = labelRow), aes(x = 0, y = y, label = gene)) + geom_text_repel(min.segment.length = grid::unit(0, "pt"), color = "grey30", ## ggplot2 theme_grey() axis text size = 0.8*11/.pt ## ggplot2 theme_grey() axis text ) + scale_x_continuous(limits = c(0, 1), expand = c(0, 0), breaks = NULL, labels = NULL, name = NULL) + scale_y_continuous(limits = c(0.5, 100.5), expand = c(0, 0), breaks = NULL, labels = NULL, name = NULL) + theme(panel.background = element_blank(), plot.margin = margin(0, 0, 0, 0, "pt")) # align and combine aligned <- align_plots(heatmap + theme(legend.position = "none"), axis, align = "h", axis = "tb") aligned <- append(aligned, list(get_legend(heatmap))) plot_grid(plotlist = aligned, nrow = 1, rel_widths = c(5, .5, .7))
For these kinds of problems, I prefer to draw the axis as a separate plot and then combine. It takes a bit of fiddling but allows you to draw pretty much any axis you want.
In my solution, I'm using the functions
get_legend()
,align_plots()
, andplot_grid()
from the cowplot package. Disclaimer: I'm the package author.library(ggplot2) library(cowplot); theme_set(theme_gray()) # undo cowplot theme setting library(ggrepel) df<-data.frame() for (i in 1:50){ tmp_df <- data.frame(cell=paste0("cell", i), gene=paste0("gene", 1:100), exp=rnorm(100), ident=i%%5) df<-rbind(df, tmp_df) } labelRow <- rep("", 100) genes <- c(2, 5, 7, 11, 19, 23) labelRow[genes] <- paste0("gene ", genes) # make the heatmap plot heatmap <- ggplot(data = df, mapping = aes(x = cell,y = gene, fill = exp)) + geom_tile() + scale_fill_gradient2(name = "Expression") + scale_x_discrete(expand = c(0, 0), drop = TRUE) + facet_grid(facets = ~ident, drop = TRUE, space = "free", scales = "free", switch = "x") + theme(axis.line = element_blank(), axis.title = element_blank(), axis.text = element_blank(), axis.ticks = element_blank(), strip.text.x = element_text(angle = -90), legend.justification = "left", plot.margin = margin(5.5, 0, 5.5, 5.5, "pt")) # make the axis plot axis <- ggplot(data.frame(y = 1:100, gene = labelRow), aes(x = 0, y = y, label = gene)) + geom_text_repel(min.segment.length = grid::unit(0, "pt"), color = "grey30", ## ggplot2 theme_grey() axis text size = 0.8*11/.pt ## ggplot2 theme_grey() axis text ) + scale_x_continuous(limits = c(0, 1), expand = c(0, 0), breaks = NULL, labels = NULL, name = NULL) + scale_y_continuous(limits = c(0.5, 100.5), expand = c(0, 0), breaks = NULL, labels = NULL, name = NULL) + theme(panel.background = element_blank(), plot.margin = margin(0, 0, 0, 0, "pt")) # align and combine aligned <- align_plots(heatmap + theme(legend.position = "none"), axis, align = "h", axis = "tb") aligned <- append(aligned, list(get_legend(heatmap))) plot_grid(plotlist = aligned, nrow = 1, rel_widths = c(5, .5, .7))
相关问答
更多-
如何处理ggplot2和离散轴上的重叠标签(How to deal with ggplot2 and overlapping labels on a discrete axis)[2022-07-10]
我试图拼凑一个不同版本的new_lines_adder : new_lines_adder = function(test.string, interval) { #split at spaces string.split = strsplit(test.string," ")[[1]] # get length of snippets, add one for space lens <- nchar(string.split) + 1 # now the trick: spl ... -
如何调整散焦轴上的刻度数(标签在小数字上重叠)(how to adjust # of ticks on Bokeh axis (labels are overlapping on small figures))[2023-06-22]
看起来似乎还没有直接的方式来指定它。 请遵循相关问题 。 这是一个解决方法: from bokeh.models import SingleIntervalTicker, LinearAxis plot = bp.figure(plot_width=800, plot_height=200, x_axis_type=None) ticker = SingleIntervalTicker(interval=5, num_minor_ticks=10) xaxis = LinearAxis(ticker=ti ... -
我现在有了这个来组织标签: https://www.facebook.com/rgraph/posts/1181898698528654:0 I've now got this to organise the labels: https://www.facebook.com/rgraph/posts/1181898698528654:0
-
你的par(oma=c(3,3,0,0))行应该在第一个par(mar=...)调用之前,因为它应该应用于整个设备区域(即你不能改变大小如果您已经绘制了一些图表,则为外边距)。 scatterhist = function(x, y, xlab="", ylab=""){ zones=matrix(c(2,0,1,3), ncol=2, byrow=TRUE) layout(zones, widths=c(4/5,1/5), heights=c(1/5,4/5)) par(oma=c ...
-
错误在于ggrepel::geom_label_repel()中的line mapping = aes(label = mean) ggrepel::geom_label_repel() 。 您可以尝试以下操作:首先创建一个包含每种变量Sepal.Length的平均值的数据集。 mean_dat <- aggregate(data = iris[, c(1, 5)], . ~Species, FUN = mean) names(mean_dat) <- c("Species", "mean_label") ...
-
这是一个想法: 在您想要的任意组中切出Dimension1列,按形成的剪切变量进行分组,粘贴类别名称并计算y坐标。 我将文本和点映射到相同的颜色,但没有必要。 library(tidyverse) d1 %>% arrange(desc(Dimension1)) %>% mutate(cut = cut(Dimension1, 32), X = 0) %>% group_by(cut) %>% mutate(label = paste(Category, collaps ...
-
使用plotly_build()调整边距。 从文档: 使用此函数可用于覆盖ggplotly / plot_ly提供的默认值或调试渲染错误。 pb <- plotly_build(plot) str(pb) pb$layout$margin$b <- 220 pb Use plotly_build() to adjust the margins. From the documentation: Using this function can be useful for overriding defaults ...
-
这里是在geom_label_repel使用xlim和ylim的geom_label_repel : library(ggplot2) library(ggrepel) set.seed(1) iris2 <- iris[sample(1:nrow(iris), 20),] ggplot(iris2, aes(x=Sepal.Length,y=Sepal.Width)) + geom_point() + geom_label_repel(aes(label=Species), xlim=c(6,8), y ...
-
显然,日期轴渲染器特别存在某些与空值有关的问题。 如果其他渲染器将跳过该值并移动到下一个适当的x位置,则此渲染器会将值偏移1.我的数据集中的空值越多,最终点的偏差就越大。 我现在从我的数据中过滤掉空值,现在情况正常。 Apparently the date axis renderer in particular has some sort of issue with null values. Where the other renderer's would skip the value and move t ...
-
对于这些类型的问题,我更喜欢将轴绘制为单独的图,然后组合。 它需要一些摆弄,但允许您绘制几乎任何你想要的轴。 在我的解决方案中,我正在使用cowplot包中的函数get_legend() , align_plots()和plot_grid() 。 免责声明:我是包裹作者。 library(ggplot2) library(cowplot); theme_set(theme_gray()) # undo cowplot theme setting library(ggrepel) df<-data.fram ...