I am drawing a pie chart in a box on shiny dashboard through plot_ly. Not able to get it in the center of the box.
layout(xaxis = list(title = MVNO",align='center', showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list( showgrid = FALSE, zeroline = FALSE , showticklabels = FALSE))
Related
Where do i insert tracegroupgap in this code? I have tried in legend=(dict.. without success.
layout = go.Layout(
title = 'IGS',
xaxis = dict(title = "Point", tickmode='linear', tick0=0, dtick=10),
yaxis = dict(title = "sp, mv"),
hovermode = 'closest',
legend = dict(font=dict(family="Courier",
size=10,
color="black"),
*tracegroupgap = 5*
)
)
buttons are generated from sql database. When you run only one application, the widget refreshes itself. By clicking successive buttons, the text in the groupbox changes correctly, while the vbox in the groupbox is only pressed. Code below.
def GuiClient(self):
self.vbox_klient = QVBoxLayout()
klienci_button = QHBoxLayout()
buttons_klienci_layout = QGridLayout()
baza = sql.DB()
klienci = baza.listNameClients()
buttons ={}
for b in range(len(self.lista_klient)):
buttons[self.lista_klient[b]] = (0, lista_pos[b])
self.group_button_klienci = QButtonGroup()
self.group_button_klienci.buttonClicked[int].connect(self.one_button_click_clients)
for btn_txt, pos in buttons.items():
buttons[btn_txt] = QPushButton(btn_txt)
buttons[btn_txt].setFixedSize(120, 35)
buttons_klienci_layout.addWidget(buttons[btn_txt], pos[0], pos[1])
buttons[btn_txt].setCheckable(True)
self.group_button_klienci.addButton(buttons[btn_txt], pos[1])
klienci_button.addLayout(buttons_klienci_layout)
self.vbox_klient.addLayout(klienci_button)
self.klient_body = QVBoxLayout()
self.group_klient_null = QGroupBox('Clients')
self.klient_body.addWidget(self.group_klient_null)
self.group_klient_select = QGroupBox(self)
self.group_klient_select.setVisible(False)
self.klient_body.addWidget(self.group_klient_select)
self.vbox_klient.addLayout(self.klient_body)
def one_button_click_clients(self, num_kl):
if num_kl < 0:
self.group_klient_null.setVisible(True)
self.group_klient_select.setVisible(False)
if num_kl >=0:
temp = num_kl+1
indeks_client = num_kl +1
self.group_klient_select.setTitle(self.lista_klient[num_kl])
self.group_klient_null.setVisible(False)
self.group_klient_select.setVisible(True)
vbox = QVBoxLayout()
buton =QPushButton()
buton.setText('OK' + self.lista_klient[num_kl])
vbox.addWidget(buton)
print(self.lista_klient[num_kl])
self.group_klient_select.setLayout(vbox)
I am trying to figure out how to better visualize ggiraph charts on Shiny apps. Here is the problem: the charts look awesome on desktop and mobile but they leave too much space underneath them when on mobile.
On desktop
Here is what I see on mobile:
Vertical mess
This is the layout of the app:
# Define UI for application
ui <- fixedPage(
tags$style(HTML("
body {
background-color: white;
color: black;
font-family: 'Garamond'
}
h2 {
font-family: 'Garamond';
}
.shiny-input-container {
color: #474747;
}")),
fluidRow(girafeOutput('ggplot'),
selectInput(
inputId = 'Country',
label = 'Countries and territories',
choices = c(unique(speed_data$location)),
multiple = FALSE,
selected = 'Europe'
)),
fluidRow(style='height:40vh')
)
# Define server logic required to draw a histogram
server <- function(input, output,session) {
dat = reactive({
speed_data %>%
filter(location == input$Country)
})
map = reactive({
subset(world, !(is.na(world$value)))
})
output$ggplot <- renderGirafe({gg = ggplot(dat(), aes(
x = date, y = value)) +
geom_line_interactive(aes(group = location, y = value, tooltip = location, color = location)) +
scale_y_continuous(labels = scales::comma) +
scale_color_brewer(palette = 'Set1') +
picci + theme(legend.title = element_blank(),
axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1),
legend.position = 'none') +
labs(title = paste("Pandemic's speed |", c(dat()$location)),
subtitle = 'Daily new cases difference (rolling average, 20 days)',
caption = 'SOURCE: Our world in data',
x = '',
y = '')
ggiraph(code = print(gg),
options = list(
opts_hover(css = "stroke:#5eba7d88;cursor:pointer;")))
})
}
# Run the application
shinyApp(ui = ui, server = server)
THe solution for this problem is to put
girafeOutput('myggiraphplot',height = '75%')
And it works just fine.
I'm struggling with getting my plot title to the center using ggsurvplot...
I've seen some posts mentioning something like xxxx$plot + theme(....)
but this solution does not seem to work for me.
Here's my code, maybe you can see what I'm missing:
surv_object_CA19.9 <- Surv(time = data_OS$OS_Days / 30, event = data_OS$Status.Death)
CA19.9_surv_fit <- survfit(surv_object_CA19.9 ~ CA19.9.initial_status, data = data_OS)
CA19.9_OS <- ggsurvplot(CA19.9_surv_fit, data = data_OS, pval = TRUE, xlab = "Time [Months]",
ylab = "Overall survival", risk.table = TRUE, legend.title = "",
risk.table.col. = "strata", risk.table.y.text = FALSE, surv.scale = "percent",
break.x.by = 6, xlim = c(0, 60), legend.labs = c("Pathological", "Normal"),
title = "Overall survival for patients with initially pathological or normal CA19-9 values",
CA19.9_OS$plot + theme(plot.title = element_text(hjust = 0.5)))
Thank you for any help! I'm still new to R and not particularly a friend of it yet, so any tips are highly appreciated!
One relatively easy solution is to define your own custom theme based off of the theme that is used in ggsurvplot(). Looking at the documentation for the function shows us that it is applying via ggtheme= the theme theme_survminer(). We can create a custom function that uses %+replace% to overwrite one of the theme elements of interest from theme_survminer():
custom_theme <- function() {
theme_survminer() %+replace%
theme(
plot.title=element_text(hjust=0.5)
)
}
Then, you can use that theme by association with the ggtheme= argument of ggsurvplot():
library(ggplot2)
library(survminer)
require("survival")
fit<- survfit(Surv(time, status) ~ sex, data = lung)
ggsurvplot(fit, data = lung, title='Awesome Plot Title', ggtheme=custom_theme())
#Add parameters to your theme as follows
centr = theme_grey() + theme(plot.title = element_text(hjust = 0.5, face = "bold"))
#Fit the model
fit<- survfit(Surv(time, status) ~ sex, data = lung)
#create survival plot
ggsurvplot(fit, data = lung, title="Your Title Here", ggtheme=centr)
How to increase the size of the text inside the red circle of the cor plot?
Used code:
par(mar=c(1,1,1,1))
pairs.panels(data,
method = "pearson",
hist.col = "#00AFBB",
density = TRUE,
ellipses = TRUE,
pch = 21,
cex = 1.5,
cex.axis = 1.8,
lwd = 2,
rug = TRUE,
stars = TRUE
)
Finally, I got the answer and i.e. to add the argument cex.labels = 2.5,
the final code is
library(psych)
par(mar=c(1,1,1,1))
pairs.panels(data,
method = "pearson",
hist.col = "#00AFBB",
density = TRUE,
ellipses = TRUE,
pch = 21,
cex = 1.5,
cex.axis = 1.8,
cex.labels = 2.5,
lwd = 2,
rug = TRUE,
stars = TRUE
)