RamKiran_CSV_ChartAnalysis / visualizer.pyfile
manikantachary18's picture
Create visualizer.pyfile
9ad1c41 verified
raw
history blame
562 Bytes
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