How to get rid of plotly bar chart background color

Advertisements I have the following code: def get_amp_graph(): ampfig = go.Figure(go.Bar(x=[‘1540’, ‘Average’], y=get_amp_acc())) ampfig.update_layout(plot_bgcolor=’rgb(28, 28, 28)’) amp_html = ampfig.to_html ( include_plotlyjs=True, full_html=False, ) return amp_html I want the background color to be rgb(28, 28, 28), but then this happens. How could I make the remaining white also turn rgb(28, 28, 28) >Solution : To make… Read More How to get rid of plotly bar chart background color

Formatting a plotly plot with many subplots in R

Advertisements please I have the following data and plot with subplots: library(plotly) # Create example data set.seed(123) df <- data.frame( DATE = seq(as.Date("2021-01-01"), as.Date("2021-01-10"), by = "day"), FEATURE1 = rnorm(10), FEATURE2 = rnorm(10), FEATURE3 = rnorm(10), FEATURE4 = rnorm(10), FEATURE5 = rnorm(10), FEATURE6 = rnorm(10), FEATURE7 = rnorm(10), FEATURE8 = rnorm(10), FEATURE9 = rnorm(10), FEATURE10… Read More Formatting a plotly plot with many subplots in R

Passing arguments to a nested function in Python

Advertisements I have two functions, called update_y_with_x and update_x which are as follows: update_y_with_x def update_y_with_x(chosen_tissue): for i, trace in enumerate(f.data): if trace.type == "scatter": # reset all line width f.data[i].line.width = 1 if chosen_tissue in trace.text: f.data[i].line.width = 1 + 9 update_x def update_x(trace, points, selector): if len(points.point_inds) == 0: return # Remove existing… Read More Passing arguments to a nested function in Python

How to add space between bars using Plotly?

Advertisements import plotly.express as px df = px.data.tips() fig = px.histogram( pd.DataFrame({‘price’: prices}), x="price", ) fig.show() Is there a way to separate the different bins? >Solution : You can use ‘update_layout(bargap=<gap_value>’ before show it! And for a better visualization, you can group bars by a range, like 10 to 20. import plotly.express as px import… Read More How to add space between bars using Plotly?

How to add text at barchart, when y is a list, using plotly express

Advertisements I have the following pandas dataframe import pandas as pd foo = pd.DataFrame({‘country’: {0: ‘a’, 1: ‘b’, 2: ‘c’, 3: ‘d’, 4: ‘e’}, ‘unweighted’: {0: 18.0, 1: 16.9, 2: 13.3, 3: 11.3, 4: 13.1}, ‘weighted_1’: {0: 17.7, 1: 15.8, 2: 14.0, 3: 11.2, 4: 12.8}, ‘weighted_2’: {0: 17.8, 1: 15.8, 2: 14.0, 3: 11.2,… Read More How to add text at barchart, when y is a list, using plotly express

How do I remove hover from plotly graph produced with ggplotly or toWebGL

Advertisements I have a shinyapp and use plotly-Plots. I have to use webGL, otherwise I do not get an acceptable performance. However it seems, the approach for removing hover here Remove hover info text from a plotly object does not work. My minimal example: library(shiny) library(ggplot2) library(plotly) ui <- fluidPage( plotlyOutput("po") ) server <- function(input,… Read More How do I remove hover from plotly graph produced with ggplotly or toWebGL

React Json data from endpoint not working with Plotly

Advertisements I’m learning React and trying to understand what I’m doing wrong. I have an endpoint like this in main.py: def get_db_data(): engine = create_engine(config.get(‘database’, ‘con’)) table = ‘raw_data’ df = pd.read_sql(table, engine) return df @app.get("/rawdata", tags=[‘data’], status_code=200) async def raw_data(): data = get_db_data() return data.to_dict() for the sake of brevity, it renders a Pandas… Read More React Json data from endpoint not working with Plotly

Python Plotly how to show axis values outside your dataset's max value?

Advertisements import plotly.express as px import pandas as pd df = pd.DataFrame(dict( r=[1,2,3], theta=[‘a’, ‘b’,’c’])) fig = px.line_polar(df, r=[1,2,3], theta=[‘a’,’b’,’c’], line_close=True) fig.update_polars(radialaxis_tickvals=[1,2,3,4,5], radialaxis_tickmode=’array’) fig.show() I have code like so that is able to generate a polar chart that looks like below However what I want is to ensure that the maximum value of my tickvals… Read More Python Plotly how to show axis values outside your dataset's max value?