diff --git a/Data Visualisation/Bar Chart/BarChart.py b/Data Visualisation/Bar Chart/BarChart.py new file mode 100644 index 000000000000..3e448d8bb2d4 --- /dev/null +++ b/Data Visualisation/Bar Chart/BarChart.py @@ -0,0 +1,40 @@ +import plotly.graph_objects as go +import numpy as np + +np.random.seed(42) + +# declaring size of arr +size = 7 + +x = [f'Product {i}' for i in range(size)] +y = np.random.randint(low=0, high=100, size=size) + +# creating the Bar Chart +fig = go.Figure(go.Bar( + x=x, + y=y, + text=y, + textposition='outside', + marker_color='indianred', + hovertemplate="%{x} : %{y} ", + showlegend=False, +)) + +# Modifying the tickangle of the xaxis, and adjusting width and height of the image +fig.layout.template = 'plotly_dark' +# Hiding y-axis labels +layout_yaxis_visible = False +layout_yaxis_showticklabels = False +fig.update_layout( + xaxis_title='X Axis Title', + yaxis_title='Y Axis Title', + xaxis_tickangle=-45, + autosize=False, + width=600, + height=600, + margin=dict(l=50, r=50, b=100, t=100, pad=4) +) +# Removing the background grid and the Y-axis labels +fig.update_yaxes(showgrid=False, showticklabels=False) + +fig.show() \ No newline at end of file diff --git a/Data Visualisation/Bar Chart/barchart.png b/Data Visualisation/Bar Chart/barchart.png new file mode 100644 index 000000000000..bfe85d9ce2d6 Binary files /dev/null and b/Data Visualisation/Bar Chart/barchart.png differ diff --git a/Data Visualisation/Bubble Chart/BubbleChart.png b/Data Visualisation/Bubble Chart/BubbleChart.png new file mode 100644 index 000000000000..a581b788139a Binary files /dev/null and b/Data Visualisation/Bubble Chart/BubbleChart.png differ diff --git a/Data Visualisation/Bubble Chart/BubbleChart.py b/Data Visualisation/Bubble Chart/BubbleChart.py new file mode 100644 index 000000000000..8bf1c3d8b547 --- /dev/null +++ b/Data Visualisation/Bubble Chart/BubbleChart.py @@ -0,0 +1,39 @@ +import plotly.graph_objects as go +import numpy as np + +np.random.seed(1) + +# declaring size of arr +size = 10 +size_arr = np.random.randint(low=50, high=600, size=size) + +x = np.random.randint(low=0, high=30, size=size) +y = np.random.randint(low=0, high=20, size=size) + +fig = go.Figure(data=[go.Scatter( + x=x, + y=y, + mode='markers', + marker=dict( + size=size_arr, + sizemode='area', + sizeref=2.*max(size_arr)/(40.**2), + sizemin=4 + ), + hovertemplate=" x : %{x}
y : %{y}
" +)]) + +# Adjusting width and height of the image +fig.layout.template = 'plotly_dark' +fig.update_layout( + title='Bubble Chart', + xaxis_title='X Axis Title', + yaxis_title='Y Axis Title', + autosize=False, + width=600, + height=600, + margin=dict(l=50, r=50, b=100, t=100, pad=4) +) + + +fig.show() diff --git a/Data Visualisation/Contour Plots/ContourPlots.png b/Data Visualisation/Contour Plots/ContourPlots.png new file mode 100644 index 000000000000..ad69c18bd43e Binary files /dev/null and b/Data Visualisation/Contour Plots/ContourPlots.png differ diff --git a/Data Visualisation/Contour Plots/ContourPlots.py b/Data Visualisation/Contour Plots/ContourPlots.py new file mode 100644 index 000000000000..ae8a39fb96a3 --- /dev/null +++ b/Data Visualisation/Contour Plots/ContourPlots.py @@ -0,0 +1,48 @@ +import plotly.graph_objects as go +import numpy as np + +# X , Y , Z cordinates +x_cord = np.arange(0, 50, 2) +y_cord = np.arange(0, 50, 2) +z_function = np.sin((x_cord + y_cord)/2) + +fig = go.Figure(data=go.Contour(x=x_cord, + y=y_cord, + z=z_function, + colorscale='darkmint', + contours=dict( + showlabels=False, # show labels on contours + labelfont=dict( # label font properties + size=12, + color='white', + ) + ), + colorbar=dict( + thickness=25, + thicknessmode='pixels', + len=1.0, + lenmode='fraction', + outlinewidth=0, + title='Title', + titleside='right', + titlefont=dict( + size=14, + family='Arial, sans-serif') + + ), + + ) + ) + +fig.update_layout( + title='Contour Plot', + xaxis_title='X Axis Title', + yaxis_title='Y Axis Title', + autosize=False, + width=900, + height=600, + margin=dict(l=50, r=50, b=100, t=100, pad=4) +) + +fig.layout.template = 'plotly_dark' +fig.show() diff --git a/Data Visualisation/Funnel Chart/FunnelChart.png b/Data Visualisation/Funnel Chart/FunnelChart.png new file mode 100644 index 000000000000..7bb5e06b9489 Binary files /dev/null and b/Data Visualisation/Funnel Chart/FunnelChart.png differ diff --git a/Data Visualisation/Funnel Chart/FunnelChart.py b/Data Visualisation/Funnel Chart/FunnelChart.py new file mode 100644 index 000000000000..dd7b9eb4f562 --- /dev/null +++ b/Data Visualisation/Funnel Chart/FunnelChart.py @@ -0,0 +1,34 @@ +from plotly import graph_objects as go + +fig = go.Figure() + +fig.add_trace(go.Funnel( + name='India', + y=["McDonalds", "Dominoz", "PizzaHut", + "Subway", "MadOverDonuts", "Keventers"], + x=[150, 140, 40, 50, 40, 20], + textposition="inside", + textinfo="value+percent initial")) + +fig.add_trace(go.Funnel( + name='Bangladesh', + orientation="h", + y=["McDonalds", "Dominoz", "PizzaHut", "Subway"], + x=[50, 60, 40, 30], + textposition="inside", + textinfo="value+percent previous")) + +fig.add_trace(go.Funnel( + name='SriLanka', + orientation="h", + y=["McDonalds", "Dominoz", "PizzaHut", "Subway", "MadOverDonuts"], + x=[90, 70, 50, 30, 10], + textposition="outside", + textinfo="value+percent total")) + +fig.update_layout( + title="Funnel Chart for Food Sales in Asian Countries", + showlegend=True +) +fig.layout.template = 'plotly_dark' +fig.show() diff --git a/Data Visualisation/Heat Map/HeatMap.png b/Data Visualisation/Heat Map/HeatMap.png new file mode 100644 index 000000000000..a6e8ba8283d7 Binary files /dev/null and b/Data Visualisation/Heat Map/HeatMap.png differ diff --git a/Data Visualisation/Heat Map/HeatMap.py b/Data Visualisation/Heat Map/HeatMap.py new file mode 100644 index 000000000000..20b6bdd7a636 --- /dev/null +++ b/Data Visualisation/Heat Map/HeatMap.py @@ -0,0 +1,30 @@ +import plotly.express as px +import numpy as np + +np.random.seed(42) + +# declaring the size of an array +rows = 5 +columns = 3 + +data = np.random.randint(low=0, high=50, size=(columns, rows)) + +fig = px.imshow(data, + labels=dict(x="X Axis Title", y="Y Axis Title", + color="Productivity"), + x=[f'Product {i}' for i in range(rows)], + y=[f'Type {i}' for i in range(columns)], + ) + +# Modifying the tickangle of the xaxis, and adjusting width and height of the image +fig.layout.template = 'plotly_dark' +fig.update_xaxes(side="top") +fig.update_layout( + title='Heat Map ', + xaxis_tickangle=-45, + autosize=False, + width=600, + height=600, + margin=dict(l=50, r=50, b=100, t=100, pad=4) +) +fig.show() diff --git a/Data Visualisation/Histogram Plot/HistogramPlot.png b/Data Visualisation/Histogram Plot/HistogramPlot.png new file mode 100644 index 000000000000..6df52ccf1e8e Binary files /dev/null and b/Data Visualisation/Histogram Plot/HistogramPlot.png differ diff --git a/Data Visualisation/Histogram Plot/HistogramPlot.py b/Data Visualisation/Histogram Plot/HistogramPlot.py new file mode 100644 index 000000000000..cb244eb2f5f8 --- /dev/null +++ b/Data Visualisation/Histogram Plot/HistogramPlot.py @@ -0,0 +1,23 @@ +import plotly.express as px +import numpy as np + +np.random.seed(0) + +# declaring size of arr +size = 50 + +data = np.random.randint(low=0, high=150, size=size) +# create the bins +fig = px.histogram(x=data, labels={'x': 'data', 'y': 'count'}) + +fig.layout.template = 'plotly_dark' +fig.update_layout( + title='Histogram', + xaxis_title='X Axis Title', + yaxis_title='Y Axis Title', + autosize=False, + width=600, + height=600, + margin=dict(l=50, r=50, b=100, t=100, pad=4) +) +fig.show() diff --git a/Data Visualisation/Line Chart/LineChart.py b/Data Visualisation/Line Chart/LineChart.py new file mode 100644 index 000000000000..db7c2c824952 --- /dev/null +++ b/Data Visualisation/Line Chart/LineChart.py @@ -0,0 +1,33 @@ +import plotly.graph_objects as go +import numpy as np + + +def create_line_chart(x_data, y_data): + fig = go.Figure(data=go.Scatter(x=x_data, y=y_data)) + + # Modifying the tickangle of the xaxis, and adjusting width and height of the image + fig.layout.template = 'plotly_dark' + fig.update_layout( + title='Line Chart', + xaxis_title='X Axis Title', + yaxis_title='Y Axis Title', + xaxis_tickangle=-45, + autosize=False, + width=600, + height=600, + margin=dict(l=50, r=50, b=100, t=100, pad=4) + ) + fig.show() + + +if __name__ == "__main__": + np.random.seed(42) + + # Generating sample data + x_data = np.arange(10) + y_data = x_data ** 2 + + try: + create_line_chart(x_data, y_data) + except Exception as e: + print("An error occurred:", str(e)) diff --git a/Data Visualisation/Pie Chart/PieChart.png b/Data Visualisation/Pie Chart/PieChart.png new file mode 100644 index 000000000000..2758b5be668b Binary files /dev/null and b/Data Visualisation/Pie Chart/PieChart.png differ diff --git a/Data Visualisation/Pie Chart/PieChart.py b/Data Visualisation/Pie Chart/PieChart.py new file mode 100644 index 000000000000..b92fb285d877 --- /dev/null +++ b/Data Visualisation/Pie Chart/PieChart.py @@ -0,0 +1,28 @@ +import plotly.graph_objects as go +import numpy as np + +np.random.seed(42) + +# declaring size of arr +size = 7 + +x = [f'Product {i}' for i in range(size)] +y = np.random.randint(low=0, high=100, size=size) + +# creating a Pie Chart +fig = go.Figure(data=[go.Pie(labels=x, values=y)]) + +# Adjusting width and height of the image +fig.layout.template = 'plotly_dark' +# To display labels with the percentage +fig.update_traces(textposition='inside', textinfo='percent+label') +fig.update_layout( + title='Pie Chart', + xaxis_title='X Axis Title', + yaxis_title='Y Axis Title', + autosize=False, + width=600, + height=600, + margin=dict(l=50, r=50, b=100, t=100, pad=4) +) +fig.show() diff --git a/Data Visualisation/Scatter Plot/ScatterPlot.png b/Data Visualisation/Scatter Plot/ScatterPlot.png new file mode 100644 index 000000000000..262e8e2e76a8 Binary files /dev/null and b/Data Visualisation/Scatter Plot/ScatterPlot.png differ diff --git a/Data Visualisation/Scatter Plot/ScatterPlot.py b/Data Visualisation/Scatter Plot/ScatterPlot.py new file mode 100644 index 000000000000..c8c786d4f17a --- /dev/null +++ b/Data Visualisation/Scatter Plot/ScatterPlot.py @@ -0,0 +1,25 @@ +import plotly.express as px +import numpy as np + +np.random.seed(42) + +# declaring size of arr +size = 100 + +x = np.random.randint(low=0, high=100, size=size) +y = np.random.randint(low=0, high=100, size=size) + +fig = px.scatter(x=x, y=y) + +# Adjusting width and height of the image +fig.layout.template = 'plotly_dark' +fig.update_layout( + title='Scatter Plot', + xaxis_title='X Axis Title', + yaxis_title='Y Axis Title', + autosize=False, + width=600, + height=600, + margin=dict(l=50, r=50, b=100, t=100, pad=4) +) +fig.show() diff --git a/Data Visualisation/Ternary Plots/TernaryPlots.png b/Data Visualisation/Ternary Plots/TernaryPlots.png new file mode 100644 index 000000000000..bb64bae3005f Binary files /dev/null and b/Data Visualisation/Ternary Plots/TernaryPlots.png differ diff --git a/Data Visualisation/Ternary Plots/TernaryPlots.py b/Data Visualisation/Ternary Plots/TernaryPlots.py new file mode 100644 index 000000000000..6df642cad0c1 --- /dev/null +++ b/Data Visualisation/Ternary Plots/TernaryPlots.py @@ -0,0 +1,30 @@ +import plotly.express as px +import plotly.graph_objects as go + +df = px.data.election() + +fig = go.Figure(go.Scatterternary({ + 'mode': 'markers', + 'a': df['Joly'], + 'b': df['Coderre'], + 'c': df['Bergeron'], + 'marker': { + 'color': 'green', + 'size': 14, + }, + +})) +fig.update_layout({ + 'title': 'Ternary Scatter Plot', + 'ternary': + { + 'sum': 1, + 'aaxis': {'title': 'Joly', 'min': 0.01, 'linewidth': 2, 'ticks': 'outside'}, + 'baxis': {'title': 'Coderre', 'min': 0.01, 'linewidth': 2, 'ticks': 'outside'}, + 'caxis': {'title': 'Bergeron', 'min': 0.01, 'linewidth': 2, 'ticks': 'outside'} + }, + 'showlegend': False +}) + +fig.layout.template = 'plotly_dark' +fig.show() diff --git a/Data Visualisation/Waterfall Chart/WaterfallChart.py b/Data Visualisation/Waterfall Chart/WaterfallChart.py new file mode 100644 index 000000000000..ae282c04a43b --- /dev/null +++ b/Data Visualisation/Waterfall Chart/WaterfallChart.py @@ -0,0 +1,25 @@ +import plotly.express as px +import plotly.graph_objects as go + +fig = go.Figure(go.Waterfall( + name="20", + orientation="v", + measure=["relative", "relative", "relative", + "relative", "relative", "total"], + x=["Exp1", "Exp2", "Exp3", "Exp4", "Exp5", "Exp6"], + textposition="outside", + text=["100", "50", "130", "200", "40", "Total"], + y=[100, +50, 130, 200, 40, 0], + connector={"line": {"color": "rgb(63, 63, 63)"}}, + increasing={"marker": {"color": "green"}}, + totals={"marker": {"color": "blue"}} +)) + +fig.update_layout( + title="Waterfall Chart", + showlegend=True, + xaxis_title='X Axis Title', + yaxis_title='Y Axis Title', +) +fig.layout.template = 'plotly_dark' +fig.show()