import plotly.express as px def create_plot(df, chart_type, x_col, y_col): if chart_type == "Bar Chart": fig = px.bar(df, x=x_col, y=y_col) elif chart_type == "Line Chart": fig = px.line(df, x=x_col, y=y_col) elif chart_type == "Scatter Plot": fig = px.scatter(df, x=x_col, y=y_col) elif chart_type == "Pie Chart": fig = px.pie(df, names=x_col, values=y_col) elif chart_type == "Box Plot": fig = px.box(df, x=x_col, y=y_col) else: raise ValueError("Invalid chart type") return fig