我有一个像下面这样的图,我需要在其中显示一个图标题和一些长的方面标签。在ggplot2,它看起来很好。
代表:
library(ggplot2)
library(stringr)
library(plotly)
iris$Species2 <- paste(iris$Species, "... some text to make the label really long and hard to put on a facet label")
iris$Species2 <- str_wrap(iris$Species2, 20)
g <- ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) +
geom_point() +
labs(title = "This title isn't helping anyone") +
facet_wrap(~Species2)
g
Run Code Online (Sandbox Code Playgroud)
但是,转换为动态图并没有按预期工作......刻面标签被切断并进入标题:
gp <- ggplotly(g)
gp
Run Code Online (Sandbox Code Playgroud)
之前有一个关于 this 的 SO question,但看起来 OP 没有尝试答案 - 没有人发现建议的答案没有按预期工作。
plotly当涉及到方面时,我对奇怪的行为并不陌生- 请参阅github 上的对话,但我不太了解plotly修改对象以强制它具有更长的 strip.background。
希望有人可以帮助我修改对象gp …
假设我想在R Markdown文件(html输出)中显示几个方程的系数表.
我希望桌子看起来像这样:
但我不能为我的生活弄清楚如何告诉R Markdown解析表中的列名.
我最接近的是一个hacky解决方案,使用cat从我的data.frame打印自定义表...不理想.有一个更好的方法吗?
这是我在上面创建图像的方法,将我的文件保存为RStudio中的.Rmd.
---
title: "Math in R Markdown tables"
output:
html_notebook: default
html_document: default
---
My fancy table
```{r, echo=FALSE, include=TRUE, results="asis"}
# Make data.frame
mathy.df <- data.frame(site = c("A", "B"),
b0 = c(3, 4),
BA = c(1, 2))
# Do terrible things to print it properly
cat("Site|$\\beta_0$|$\\beta_A$")
cat("\n")
cat("----|---------|---------\n")
for (i in 1:nrow(mathy.df)){
cat(as.character(mathy.df[i,"site"]), "|",
mathy.df[i,"b0"], "|",
mathy.df[i,"BA"],
"\n", sep = "")
}
```
Run Code Online (Sandbox Code Playgroud) 我想将sf对象导出为.kml文件,并带有我感兴趣的每个功能的标签,以便我可以在 Google 地球中轻松查看数据。我知道您可以点击 Google 地球中的“信息”按钮,但是对于数百个多边形来说,这并不理想。
例如,我想使用 column 标记下面的每个多边形特征NAME。如何修改st_write下面的调用以标记 kml 多边形,以便它们出现在 Google 地球的侧边栏目录中?
library(sf)
library(dplyr)
# sf includes this dataset
county_polygons <- st_read(system.file("shape/nc.shp", package="sf")) %>%
st_transform(4326)
st_write(county_polygons , "test.kml", driver = "kml")
Run Code Online (Sandbox Code Playgroud)
这是一张图片,显示了将其作为 kml 文件导入时 Google 地球中缺少标签的情况:
我正在 R 中创建传单地图 - 我不需要构建闪亮的应用程序,并且还没有解决该特定技能!
我试图按照这里的这篇文章在我的图例中创建圆圈: 用圆圈传单 R 创建图例。
但是,我不确定如何将该tags$style属性作为@K合并到我的 R 代码中。Rhode 建议确保图例项为圆形。在我的代码中,图例出现了正方形。很近!
任何人都可以帮助我推动此代码使图例项圈起来吗?
library(leaflet)
library(dplyr)
#create data
Points<-data.frame(x=runif(10,20,21), y=runif(10,0,1),
var=c(rep(c(10,20, 40),3), 20))
Points <- Points %>%
mutate(Category = case_when(var == 10 ~ "A",
var == 20 ~ "B",
TRUE ~ "C"),
color = case_when(Category == "A" ~ "blue",
Category == "B" ~ "blue",
TRUE ~ "red"))
map = leaflet() %>%
addTiles()
addLegendCustom <- function(map, colors, labels, sizes, opacity = 0.5){
colorAdditions <- paste0(colors, "; width:", sizes, …Run Code Online (Sandbox Code Playgroud) 我正在将大约 9000 张照片从 .NEF 转换为 .jpg。
我刚刚开始从命令行使用 ImageMagick。我也安装了Exiftool。我正在使用该mogrify命令,因为它可以很好地处理批次。
当我跑
mogrify -format jpg *.NEF
Run Code Online (Sandbox Code Playgroud)
我所有的 .NEF 文件都成功转换为 JPG,但所有 EXIF 数据都丢失了。
我已经搜索了很多来尝试找到解决方案,似乎我可能需要安装 ufraw,但如果可能的话,我想要一个使用我已经拥有的软件的解决方案 - ImageMagick和Exiftool。
预先感谢您提供有关如何执行此操作的任何建议。
更新:
-quality 100在 ImageMagick 中指定时,图像大小增加了大约 45 MB!为什么?exiftool -tagsfromfile %d%f.NEF -ext jpg -overwrite_original .将 exif 信息添加到 JPG。r ×4
css ×1
exif ×1
exiftool ×1
facet-wrap ×1
ggplot2 ×1
ggplotly ×1
html-table ×1
imagemagick ×1
javascript ×1
jpeg ×1
kml ×1
label ×1
leaflet ×1
mogrify ×1
r-markdown ×1
r-plotly ×1
r-sf ×1