[Python] How do I create a Bar Plot using CSV file, Pandas & Plotly or any other method that...

Discussão em 'Python' iniciado por Stack, Maio 2, 2025.

  1. Stack

    Stack Membro Participativo

    Is there a way to make a Bar Chart not be this small? I have thousands of horizontal bars in my chart, so I want to scroll up/down and every time I add a new plot the chart data keeps shrinking? I want to keep scrolling without any changes in size, is this possible?

    import pandas as pd
    import plotly.graph_objects as go
    from dash import Dash, html, dcc

    # Load data from CSV
    csv_file = 'prices.csv'
    df = pd.read_csv(csv_file)

    # Create the Dash app
    app = Dash(__name__)

    # Define the layout of the app
    app.layout = html.Div(
    [
    dcc.Graph(
    figure=go.Figure(
    data=[go.Bar(y=df['price'], x=df['list'], orientation='h')],
    layout={
    'height': 2500 # Adjust height to control scrollbar visibility
    }
    )
    ),
    ],
    style={
    'overflow-y': 'auto',
    'height': 800 # Set a fixed height for the scrollable area
    }
    )

    if __name__ == '__main__':
    app.run(debug=True)


    What it presently looks like: [​IMG]

    At the end I want to achieve a plot like below (Source: Random Image on the Internet)` [​IMG]

    Continue reading...

Compartilhe esta Página