Giter Club home page Giter Club logo

Comments (3)

wch avatar wch commented on June 9, 2024 1

Sorry for taking so long to reply! The shinylive.io web interface does support plotnine, but it must be in the context of a Shiny app.

However, if you're trying to run plotnine code (or matplotlib code, for that matter) from the console, there's nowhere for the plot to display. Unlike running python at the terminal, the shinylive.io web interface does not have a graphics device window which will open for plotnine. This is because the shinylive.io web interface is designed primarily for Shiny applications.

Here's a example Shiny app with your plot (and some associated shiny code around it)

This is the code for the app:

from shiny import App, render, ui

import pandas as pd

from plotnine import ggplot, aes, geom_col

app_ui = ui.page_fluid(
    ui.output_plot("plt"),
)


def server(input, output, session):
    @output
    @render.plot()
    def plt():
        df = pd.DataFrame(
            {
                "variable": [
                    "gender",
                    "gender",
                    "age",
                    "age",
                    "age",
                    "income",
                    "income",
                    "income",
                    "income",
                ],
                "category": [
                    "Female",
                    "Male",
                    "1-24",
                    "25-54",
                    "55+",
                    "Lo",
                    "Lo-Med",
                    "Med",
                    "High",
                ],
                "value": [60, 40, 50, 30, 20, 10, 25, 25, 40],
            }
        )
        df["variable"] = pd.Categorical(
            df["variable"], categories=["gender", "age", "income"]
        )
        df["category"] = pd.Categorical(df["category"], categories=df["category"])

        return ggplot(df, aes(x="variable", y="value", fill="category")) + geom_col()


app = App(app_ui, server)

from shinylive.

wch avatar wch commented on June 9, 2024

Are you trying to run this in the shinylive.io terminal, or in a Shiny app?

from shinylive.

stonebig avatar stonebig commented on June 9, 2024

In the shinylive.io website

from shinylive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.