Use a custom icon in plotly's pie chart in R
(1) Download the png file available here and save it in your working directory as man_woman.png
(2) Run the following code:
library(png)
library(plotly)
genderselection <- read.table(text="
Gender Freq
F 70
M 30
", header=T)
pcts <- round(prop.table(genderselection$Freq)*100)
# Load png file with man and woman
img <- readPNG("man_woman.png")
h <- dim(img)[1]
w <- dim(img)[2]
# Find the rows where feet starts and head ends
pos1 <- which(apply(img[,,1], 1, function(y) any(y==1)))
mn1 <- min(pos1)
mx1 <- max(pos1)
pospctM <- round((mx1-mn1)*pcts[2]/100+mn1)
pospctF <- round((mx1-mn1)*pcts[1]/100+mn1)
# Fill bodies with a different color according to percentages
imgmtx <- img[h:1,,1]
whitemtx <- (imgmtx==1)
colmtx <- matrix(rep(FALSE,h*w),nrow=h)
midpt <- round(w/2)-10
colmtx[mx1:pospctM,1:midpt] <- TRUE
colmtx[mx1:pospctF,(midpt+1):w] <- TRUE
imgmtx[whitemtx & colmtx] <- 0.5
# Plot matrix using heatmap and print text
labs <- c(paste0(pcts[2], "% Males"),paste0(pcts[1], "% Females"))
ax <- list(ticks='', showticklabels=FALSE, showgrid=FALSE, zeroline=FALSE)
p <- plot_ly(z = imgmtx, showscale=FALSE, type='heatmap', width = 500, height = 500) %>%
add_text(x = c(100,250), y = c(20,20), type='heatmap', mode="text",
text=labs, showlegend=FALSE, textfont=list(size=20, color="#FFFFFF"), inherit=FALSE) %>%
layout(xaxis = ax, yaxis = ax)
p
Create an image filled chart in R using ggplot
You really only need to modify the plotting command from the answer that @PoGibas linked: here
library(png)
library(ggplot2)
genderselection <- read.table(text="
Gender Freq
F 70
M 30
", header=T)
pcts <- round(prop.table(genderselection$Freq)*100)
# Load png file from imgur as binary
con <- url("https://i.imgur.com/vFDSFYX.png",
open='rb')
rawpng <- readBin(con, what='raw', n=50000)
close(con)
img <- readPNG(rawpng)
h <- dim(img)[1]
w <- dim(img)[2]
# Find the rows where feet starts and head ends
pos1 <- which(apply(img[,,1], 1, function(y) any(y==1)))
mn1 <- min(pos1)
mx1 <- max(pos1)
pospctM <- round((mx1-mn1)*pcts[2]/100+mn1)
pospctF <- round((mx1-mn1)*pcts[1]/100+mn1)
# Fill bodies with a different color according to percentages
# Note that this relies on the fact that the png is a bitmap.
# The png is expressed as a matrix with a cell for each pixel
# and 3 layers for r,g,b.
dim(img)
#> [1] 360 360 3
# Create a 2d matrix by just taking the red values
# Image is black and white so black corresponds to 0
# white corresponds to 1. Then change the values of
# the cells to correspond to one of three categories.
imgmtx <- img[h:1,,1]
whitemtx <- (imgmtx==1)
colmtx <- matrix(rep(FALSE,h*w),nrow=h)
midpt <- round(w/2)-10
colmtx[mx1:pospctM,1:midpt] <- TRUE
colmtx[mx1:pospctF,(midpt+1):w] <- TRUE
imgmtx[whitemtx & colmtx] <- 0.5
# Need to melt the matrix into a data.frame that ggplot can understand
df <- reshape2::melt(imgmtx)
head(df)
#> Var1 Var2 value
#> 1 1 1 0
#> 2 2 1 0
#> 3 3 1 0
#> 4 4 1 0
#> 5 5 1 0
#> 6 6 1 0
cols <- c(rgb(255,255,255,maxColorValue = 255),
rgb(209,230,244,maxColorValue = 255),
rgb(42,128,183,maxColorValue = 255))
# Then use a heatmap with 3 colours for background, and percentage fills
# Converting the fill value to a factor causes a discrete scale.
# geom_tile takes three columns: x, y, fill corresponding to
# x-coord, y-coord, and colour of the cell.
ggplot(df, aes(x = Var2, y = Var1, fill = factor(value)))+
geom_tile() +
scale_fill_manual(values = cols) +
theme(legend.position = "none")
Arrange 4 plotly pie graphs in R
Hi @sar give a look if it solves your problem:
library(plotly)
library(dplyr)
# Data
g = c("D","L","X","A","N","B")
v = c(49,14,9,7,6,5)
df1 = data.frame(group = g, value = v)
set.seed(9) # Just for reproductibility
df2 = data.frame(group = sample(g,size = nrow(df1),replace = F),
value = sample(v,size = nrow(df1),replace = F)
)
set.seed(8)
df3 = data.frame(group = sample(g,size = nrow(df1),replace = F),
value = sample(v,size = nrow(df1),replace = F)
)
set.seed(7)
df4 = data.frame(group = sample(g,size = nrow(df1),replace = F),
value = sample(v,size = nrow(df1),replace = F)
)
#Plot
plot_ly(labels = ~group, values = ~value, legendgroup = ~group,
textposition = 'outside',textinfo = 'label+percent') %>%
add_pie(data = df1, name = "DF1", domain = list(row = 0, column = 0))%>%
add_pie(data = df2, name = "DF2", domain = list(row = 0, column = 1))%>%
add_pie(data = df3, name = "DF3", domain = list(row = 1, column = 0))%>%
add_pie(data = df4, name = "DF4", domain = list(row = 1, column = 1))%>%
layout(title = "Pie Charts in Grid", showlegend = T,
grid=list(rows=2, columns=2),
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
The Output:
EDIT1:
To show "subtitles" for each pie you can use annotations, you can also change the the legend position. The drawnback of annotations is that you must specify the position(mannualy in this case).
For avoid overlaping I suggest remove textposition = 'outside'
.
You can download the plot as .png with the button on top right of the plot.
#Plot
plot_ly(labels = ~group, values = ~value, legendgroup = ~group,
textinfo = 'label+percent') %>%
add_pie(data = df1, name = "DF1", domain = list(row = 0, column = 0))%>%
add_pie(data = df2, name = "DF2", domain = list(row = 0, column = 1))%>%
add_pie(data = df3, name = "DF3", domain = list(row = 1, column = 0))%>%
add_pie(data = df4, name = "DF4", domain = list(row = 1, column = 1))%>%
layout(title = "Pie Charts in Grid", showlegend = T,
grid=list(rows=2, columns=2),
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
legend = list(y = 0.5),
annotations = list(x = c(.08, .62, .08, .62),
y = c(.78, .78, .22, .22),
text = c("Pie 1","Pie 2","Pie 3","Pie 4"),
xref = "papper",
yref = "papper",
showarrow = F
)
)
The new output is:
EDIT2:
Give a look in font or text font.
You can change text and hover text as you please with a template.
Here is an edit suggesting taking off the labels to get more space for percentage and rounding percentage to 1 decimal digit:
#Plot
plot_ly(labels = ~group, values = ~value, legendgroup = ~group, textinfo = 'label+percent',
texttemplate = "%{percent:.1%}",
hovertemplate = "%{label} <br> %{percent:.1%} <br> %{value}") %>%
add_pie(data = df1, name = "DF1", domain = list(row = 0, column = 0))%>%
add_pie(data = df2, name = "DF2", domain = list(row = 0, column = 1))%>%
add_pie(data = df3, name = "DF3", domain = list(row = 1, column = 0))%>%
add_pie(data = df4, name = "DF4", domain = list(row = 1, column = 1))%>%
layout(title = "Pie Charts in Grid", showlegend = T,
grid=list(rows=2, columns=2),
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
legend = list(y = 0.5),
annotations = list(x = c(.08, .62, .08, .62),
y = c(.78, .78, .22, .22),
text = c("Pie 1","Pie 2","Pie 3","Pie 4"),
xref = "papper",
yref = "papper",
showarrow = F
)
)
New Output:
Custom text labels in plotly pie chart
You need this function:
def get_ranks(lst, begin_with_one=False):
srtd = sorted(lst, reverse=True)
res = [srtd.index(x) for x in lst]
return [x + 1 for x in res] if begin_with_one else res
import plotly.graph_objects as go
import numpy as np
labels = list('ABCD')
values = [25,45,13,78]
fig = go.Figure(data=[go.Pie(labels=labels, values=values,
texttemplate=[f"Rank {x}" for x in get_ranks(values, begin_with_one=True)])])
fig.show()
Use as often as possible the f-strings in Python3 - they are super convenient!
Since this works only with unique list elements, I created a better index assessor:
def map_to_index(lst1, lst2):
"""Return lst1 as indexes of lst2"""
dct = {}
for i, x in enumerate(lst2):
dct[x] = dct.get(x, []) + [i]
indexes = []
for x in lst1:
indexes.append(dct[x][0])
if len(dct[x]) > 0:
dct[x] = dct[x][1:]
return indexes
And an improved get_ranks()
:
def get_ranks(lst, begin_with_one=False):
srtd = sorted(lst, reverse=True)
res = map_to_index(lst, srtd)
return [x + 1 for x in res] if begin_with_one else res
Then it works also with:
import plotly.graph_objects as go
import numpy as np
labels = list('ABCDEF')
values = [25,45,13,78,45,78] # with elements of same value
fig = go.Figure(data=[go.Pie(labels=labels, values=values,
texttemplate=[f"Rank {x}" for x in get_ranks(values, begin_with_one=True)])])
fig.show()
3D scatterplot using custom image
Here's a hacky solution that converts the image into a dataframe, where each pixel becomes a voxel (?) that we send into plotly. It basically works, but it needs some more work to:
1) adjust image more (with erosion step?) to exclude more low-alpha pixels
2) use requested color range in plotly
Step 1: import image and resize, and filter out transparent or partly transparent pixels
library(tidyverse)
library(magick)
sprite_frame <- image_read("coffee-bean-for-a-coffee-break.png") %>%
magick::image_resize("20x20") %>%
image_raster(tidy = T) %>%
mutate(alpha = str_sub(col, start = 7) %>% strtoi(base = 16)) %>%
filter(col != "transparent",
alpha > 240)
EDIT: adding result of that chunk in case useful to anyone:
sprite_frame <-
structure(list(x = c(13L, 14L, 10L, 11L, 12L, 13L, 14L, 15L,
16L, 17L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 7L,
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 6L, 7L, 8L, 9L,
10L, 11L, 12L, 13L, 14L, 15L, 16L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 13L, 14L, 15L, 19L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L,
13L, 14L, 19L, 20L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L,
13L, 18L, 19L, 20L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 17L,
18L, 19L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 15L, 16L, 17L, 18L, 19L,
2L, 3L, 4L, 5L, 6L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 2L, 3L,
4L, 5L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 1L, 2L, 3L, 9L,
10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 1L, 2L, 7L, 8L,
9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 2L, 6L, 7L, 8L, 9L,
10L, 11L, 12L, 13L, 14L, 15L, 16L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 13L, 14L, 15L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L,
14L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 4L, 5L, 6L,
7L, 8L, 9L, 10L, 11L, 6L, 7L, 8L), y = c(1L, 1L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L,
16L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 19L, 19L, 19L, 19L,
19L, 19L, 19L, 19L, 20L, 20L, 20L), col = c("#000000f6", "#000000fd",
"#000000f4", "#000000ff", "#000000ff", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000f8", "#000000f4", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000fd", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000ff",
"#000000ff", "#000000f9", "#000000ff", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000fd",
"#000000f4", "#000000ff", "#000000ff", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000ff",
"#000000fa", "#000000ff", "#000000ff", "#000000f6", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000fb", "#000000ff", "#000000ff",
"#000000ff", "#000000f3", "#000000ff", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000fa", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000f1", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000f3",
"#000000ff", "#000000ff", "#000000ff", "#000000f6", "#000000f9",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000f5", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000f5",
"#000000fc", "#000000ff", "#000000fd", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000f3", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000ff",
"#000000ff", "#000000f5", "#000000f8", "#000000ff", "#000000ff",
"#000000ff", "#000000ff", "#000000ff", "#000000ff", "#000000f4",
"#000000f1", "#000000fe", "#000000f7"), alpha = c(246L, 253L,
244L, 255L, 255L, 255L, 255L, 255L, 255L, 248L, 244L, 255L, 255L,
255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L,
255L, 255L, 255L, 255L, 255L, 255L, 253L, 255L, 255L, 255L, 255L,
255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L,
255L, 255L, 255L, 255L, 255L, 255L, 255L, 249L, 255L, 255L, 255L,
255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 253L, 244L,
255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 250L, 255L,
255L, 246L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 251L,
255L, 255L, 255L, 243L, 255L, 255L, 255L, 255L, 255L, 255L, 250L,
255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 241L, 255L,
255L, 255L, 255L, 255L, 243L, 255L, 255L, 255L, 246L, 249L, 255L,
255L, 255L, 255L, 255L, 255L, 255L, 245L, 255L, 255L, 255L, 255L,
255L, 255L, 255L, 255L, 255L, 255L, 255L, 245L, 252L, 255L, 253L,
255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 243L,
255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L,
255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L,
255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L,
255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 255L, 245L, 248L,
255L, 255L, 255L, 255L, 255L, 255L, 244L, 241L, 254L, 247L)), row.names = c(NA,
-210L), class = "data.frame")
Here's what that looks like:
ggplot(sprite_frame, aes(x,y, fill = col)) +
geom_raster() +
guides(fill = F) +
scale_fill_identity()
Step 2: bring those pixels in as voxels
pixels_per_image <- nrow(sprite_frame)
scale <- 1/40 # How big should a pixel be in coordinate space?
set.seed(2017-02-21)
d <- data.frame(x = rnorm(10), y = rnorm(10), z=1:10)
d2 <- d %>%
mutate(copies = pixels_per_image) %>%
uncount(copies) %>%
mutate(x_sprite = sprite_frame$x*scale + x,
y_sprite = sprite_frame$y*scale + y,
col = rep(sprite_frame$col, nrow(d)))
We can plot that in 2d space with ggplot:
ggplot(d2, aes(x_sprite, y_sprite, z = z, alpha = col, fill = z)) +
geom_tile(width = scale, height = scale) +
guides(alpha = F) +
scale_fill_gradient(low='burlywood1', high='burlywood4')
Or bring it into plotly. Note that plotly 3d scatters do not currently support variable opacity, so the image currently shows up as a solid oval until you're closely zoomed into one sprite.
library(plotly)
plot_ly(d2, x = ~x_sprite, y = ~y_sprite, z = ~z,
size = scale, color = ~z, colors = c("#FFD39B", "#8B7355")) %>%
add_markers()
Edit: attempt at plotly mesh3d approach
It seems like another approach would be to convert the SVG glyph into coordinates for a mesh3d surface in plotly.
My initial attempt to do this has been impractically manual:
- Load SVG in Inkscape and use "flatten beziers" option to approximate shape without bezier curves.
- Export SVG and cross fingers that file has raw coordinates. I'm new to SVGs and it looks like the output can often be a mix of absolute and relative points. Complicated further in this case since the glyph has two disconnected sections.
- Reformat coordinates as data frame for plotting with ggplot2 or plotly.
For instance, the following coords represent half a bean, which we can transform to get the other half:
library(dplyr)
half_bean <- read.table(
header = T,
stringsAsFactors = F,
text = "x y
153.714 159.412
95.490016 186.286
54.982625 216.85
28.976672 247.7425
14.257 275.602
0.49742188 229.14067
5.610375 175.89737
28.738141 120.85839
69.023 69.01
128.24827 24.564609
190.72412 2.382875
249.14492 3.7247031
274.55165 13.610674
296.205 29.85
296.4 30.064
283.67119 58.138937
258.36 93.03325
216.39731 128.77994
153.714 159.412"
) %>%
mutate(z = 0)
other_half <- half_bean %>%
mutate(x = 330 - x,
y = 330 - y,
z = z)
ggplot() + coord_equal() +
geom_path(data = half_bean, aes(x,y)) +
geom_path(data = other_half, aes(x,y))
But while this looks fine in ggplot, I'm having trouble getting the concave parts to show up correctly in plotly:
library(plotly)
plot_ly(type = 'mesh3d',
split = c(rep(1, 19), rep(2, 19)),
x = c(half_bean$x, other_half$x),
y = c(half_bean$y, other_half$y),
z = c(half_bean$z, other_half$z)
)
Drawing a custom chart in R - Displaying a time log of activites
I'd like to propose another format for the data, where each activity has a start and an end time.
Load libraries. dplyr
is only used for manipulating the dataset, and not strictly needed.
library(ggplot2)
library(dplyr)
First we read the data set
activities <- read.csv2(
text=
"Person; Activity; Activity start; Activity end
A; Activity 1; 10:30; 11:30
A; Activity 2; 12:00; 13:00
A; Activity 3; 14:00; 16:00
B; Activity 1; 10:30; 11:30
B; Activity 2; 11:30; 13:00
B; Activity 3; 14:00; 14:30"
) %>%
mutate(
Activity.start = as.POSIXct(Activity.start, format="%H:%M"),
Activity.end = as.POSIXct(Activity.end, format="%H:%M"),
Person = as.factor(Person)
)
So now we have the correct classes for the columns and we can plot this with
ggplot(activities) +
geom_rect(
aes(
xmin=Activity.start,
xmax=Activity.end,
fill=Activity,
ymin=as.numeric(Person)-.5,
ymax=as.numeric(Person)+.5)
) +
scale_y_continuous(labels=levels(activities$Person), breaks=1:2) +
geom_text(
aes(x=(Activity.start + (Activity.end - Activity.start)/2), y=as.numeric(Person), label=Activity)
) +
xlab(NULL) +
ylab("Person")
which results in
How to remove percentage labels in a pie chart created using plot_ly in R
Based on the R chart attribute reference you have to set textinfo
property to none
.
plot_ly(ds, labels = labels, values = values, type = "pie", textinfo = "none")
Related Topics
Dplyr Filter() with SQL-Like %Wildcard%
Importing Wikipedia Tables in R
Linear Interpolate Missing Values in Time Series
Multiple Colors in a Facet Strip Background
R Pheatmap: Change Annotation Colors and Prevent Graphics Window from Popping Up
Ggplot2 Bar Plot with Two Categorical Variables
Check If Value Is in Data Frame
How to Sort a Matrix by All Columns
Taking a Disproportionate Sample from a Dataset in R
How to Do Gaussian Elimination in R (Do Not Use "Solve")
Create All Possible Combiations of 0,1, or 2 "1"S of a Binary Vector of Length N
Shiny: Open New Browser Tab from Within Shiny App
Create a Variable Length 'Alist()'
Applying Revgeocode to a List of Longitude-Latitude Coordinates
Plotting Survival Curves in R with Ggplot2
Sum by Distinct Column Value in R
How to Reset All Options() Arguments to Their Default Values