library(ggplot2)
library(tidyverse)
library(ggtext)
df_x <- c(runif(6, min = 1, max = 2))
df_y <- c(rep("A", 3), rep("B", 3))
df_lab <- c("Čžěčh Přóblém", "Gërmän pröbëm töö", as.character(1:4))
tibble(df_x, df_y, df_lab) %>%
ggplot(aes(x = df_x, y = df_y, fill = df_lab)) +
geom_bar(position = "stack", stat = "identity") +
theme(legend.text = element_markdown())
I believe this to be a very basic issue, but could not find anything on how to handle this problem.
Also you can change your system locale
using the below code.
Sys.setlocale("LC_CTYPE", "Czech")
Sample code:
library(ggplot2)
library(tidyverse)
library(ggthemes)
Sys.setlocale("LC_CTYPE", "Czech")
tibble(df_x, df_y, df_lab) %>%
ggplot(aes(x = df_x, y = df_y, fill = df_lab)) +
geom_bar(position = "stack", stat = "identity") +
theme_par()+
labs(x="dfx",y="dfy")+
theme(axis.text.x = element_text(hjust = 1, face="bold", size=12, color="black"),
axis.title.x = element_text(face="bold", size=16, color="black"),
axis.text.y = element_text(face="bold", size=12, color="black"),
axis.title.y = element_text(face="bold", size=16, color="black"),
strip.text = element_text(size=10, face="bold"),
plot.title = element_text(size=20, face="bold"),
legend.position = "top",
legend.title = element_blank(),
legend.text = element_text(color = "black", size = 16,face="bold"))
Plot:
or with the legend
on the right
side
Sample data:
df_x <- c(runif(6, min = 1, max = 2))
df_y <- c(rep("A", 3), rep("B", 3))
df_lab <- c("Čžěčh Přóblém", "Gërmän pröbëm töö", as.character(1:4))