Dv With Python Programs-8,9,10
Dv With Python Programs-8,9,10
8 a) Write a Python program to explain working with bokeh line graph using Annotations
and Legends.
PROGRAM
output_file("line_graph_with_annotations.html")
# Sample data
x = [1, 2, 3, 4, 5]
y1 = [2, 5, 7, 2, 8]
y2 = [1, 4, 5, 3, 6]
x_axis_label='X-axis', y_axis_label='Y-axis')
1")
2")
line_width=8)
# Create a legend
legend = Legend(items=[
])
p.add_layout(legend)
show(p)
OUTPUT
8 b) Write a Python program for plotting different types of plots using Bokeh.
PROGRAM
import numpy as np
from bokeh.io import output_file
of Plots')
y = np.sin(x)
fig.legend.location = 'top_left'
show(fig)
OUTPUT
9) Write a Python program to draw 3D Plots using Plotly Libraries.
PROGRAM
import plotly.graph_objects as go
import pandas as pd
pubg = pd.read_csv('D:\dvwithpython_lab\Custom-Data-PUBG.csv')
#pubg.head(10)
df_new_pubg = df_pubg.head(10)
df_bar_pubg = df_pubg.head(30)
x = df_bar_pubg['solo_Wins']
y = df_bar_pubg['solo_TimeSurvived']
z = df_bar_pubg['solo_RoundsPlayed']
trace1 = go.Scatter3d(
x=x,
y=y,
z=z,
mode='markers',
marker=dict(
size=12,
color=z,
colorscale='Viridis',
opacity=0.8))
data = [trace1]
layout = go.Layout(
margin=dict(
l=0,
r=0,
b=0,
t=0)
pyo.plot(fig, filename='3d-pubg-plot.html')
OUTPUT
10 a) Write a Python program to draw Time Series using Plotly Libraries.
PROGRAM
import plotly.graph_objects as go
import pandas as pd
tesla = pd.read_csv("D:\dvwithpython_lab\Time-Series-Tesla-Stock-
Price.csv")
trace_one = go.Scatter(
x=tesla.date,
y=tesla['high'],
name="Tesla High",
line=dict(color='#17BECF'),
opacity = 0.8)
trace_two = go.Scatter(
x=tesla.date,
y=tesla['low'],
name="Tesla Low",
line=dict(color='#7F7F7F'),
opacity = 0.8)
layout = dict (
PROGRAM
#import libraries
import pandas as pd
import plotly.express as px
#import data
data = pd.read_csv('D:\\dvwithpython_lab\\2011_us_ag_exports.csv')
locationmode="USA-states",
fig.show()
OUTPUT