我想像经济学人那样将值之间的变化绘制为值之间的单个条形图:
此图称为2019-06-29T11:24:46.008853+00:00 app[web.1]: I, [2019-06-29T11:24:46.008752 #4] INFO -- : [5d839ee1-e92f-46d7-81d0-9fd508157239] Started GET "/users" for PRIVATE_IP at 2019-06-29 11:24:46 +0000
2019-06-29T11:24:46.010267+00:00 app[web.1]: I, [2019-06-29T11:24:46.010188 #4] INFO -- : [5d839ee1-e92f-46d7-81d0-9fd508157239] Processing by UsersController#index as HTML
2019-06-29T11:24:46.013170+00:00 app[web.1]: I, [2019-06-29T11:24:46.013098 #4] INFO -- : [5d839ee1-e92f-46d7-81d0-9fd508157239] Rendering users/index.html.erb within layouts/application
2019-06-29T11:24:46.055431+00:00 app[web.1]: D, [2019-06-29T11:24:46.055315 #4] DEBUG -- : [5d839ee1-e92f-46d7-81d0-9fd508157239] User Load (1.5ms) SELECT "users".* FROM "users"
2019-06-29T11:24:46.056103+00:00 app[web.1]: I, [2019-06-29T11:24:46.056041 #4] INFO -- : [5d839ee1-e92f-46d7-81d0-9fd508157239] Rendered users/index.html.erb within layouts/application (42.8ms)
2019-06-29T11:24:46.056339+00:00 app[web.1]: I, [2019-06-29T11:24:46.056280 #4] INFO -- : [5d839ee1-e92f-46d7-81d0-9fd508157239] Completed 500 Internal Server Error in 46ms (ActiveRecord: 13.4ms)
2019-06-29T11:24:46.057108+00:00 app[web.1]: F, [2019-06-29T11:24:46.057045 #4] FATAL -- : [5d839ee1-e92f-46d7-81d0-9fd508157239]
2019-06-29T11:24:46.063287+00:00 app[web.1]: F, [2019-06-29T11:24:46.057141 #4] FATAL -- : [5d839ee1-e92f-46d7-81d0-9fd508157239] ActionView::Template::Error (PG::UndefinedTable: ERROR: relation "users" does not exist
,因此如果您知道要搜索的内容,则问题很可能是重复的。
这是一个代码示例,可为两个类别绘制条形图。能够按照上面的示例进行绘制将非常棒。
dumbbell
能够将颜色降低为粉红色(例如)是一种奖励。
答案 0 :(得分:2)
这里是一个可能的解决方案,其中我使用了辅助的第二个data.frame和app:tabGravity="fill"
来绘制两个时间点之间的连接线。我还包括一些视觉自定义项,例如颜色,点类型,透明度和箭头。这些可以根据需要删除或修改。
<android.support.design.widget.TabLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMaxWidth="0dp"
app:tabGravity="fill"
app:tabMode="fixed" />
答案 1 :(得分:2)
我在ggalt包中发现了geom函数,它的功能如下:
library(ggalt)
library(data.table)
Animals <- data.table(Animals)
Animals.wide <- dcast(Animals, Reason ~ Year, value.var = "Species")
colnames(Animals.wide) <- c("Reason", "species.2018", "species.2019")
p <- ggplot(
Animals.wide,
aes(
y = Reason,
x = species.2018,
xend = species.2019
)
)
# > Animals.wide
# Reason species.2018 species.2019
# 1: Genuine 24 16
# 2: Misclassified 41 85
# 3: Taxonomic 2 7
# 4: Unclear 41 117
p <- p + geom_dumbbell(
size = 10,
color = "#C1D9E4",
colour_x = "#39C1D1",
colour_xend = "#953D4D",
dot_guide = TRUE,
dot_guide_size = 0.25,
position = position_dodgev(height = 0.4),
show.legend = TRUE
)
p <- p + scale_x_continuous(position = "top")
p <- p + theme_economist()
p <- p + xlab("Species")
p <- p + ylab(NA)
p <- p + theme(
legend.position = "top",
axis.text.y = element_text(size = 20),
axis.title.y = element_blank(),
axis.title.x = element_blank(),
axis.line.x = element_blank(),
axis.ticks.x = element_blank(),
axis.text.x = element_text(size = 20, margin = margin(-0.4, unit = "cm"))
)
p
它不如@bdemarest的解决方案灵活,但几乎可以完成工作。