Python Bokeh: trazando Y en un gráfico

Bokeh es una visualización de datos interactiva de Python. Representa sus tramas usando HTML y JavaScript. Se dirige a los navegadores web modernos para presentaciones que proporcionan una construcción elegante y concisa de gráficos novedosos con interactividad de alto rendimiento.

Bokeh se puede utilizar para trazar Ys en un gráfico. Se puede trazar Ys en un gráfico usando el y()método del plottingmódulo.

trazando.figura.y()

Sintaxis: y(parámetros)

Parámetros:

  • x : coordenadas x del centro de los marcadores y
  • y : coordenadas y del centro de los marcadores y

Devoluciones: un objeto de claseGlyphRenderer

Ejemplo 1: En este ejemplo, utilizaremos los valores predeterminados para trazar el gráfico.

# importing the modules
from bokeh.plotting import figure, output_file, show
         
# file to save the model
output_file("gfg.html")
         
# instantiating the figure object
graph = figure(title = "Bokeh Y Graph")
       
# the points to be plotted
x = 0
y = 0
      
# plotting the graph
graph.y(x, y, size = 30)
       
# displaying the model
show(graph)

Producción :

Ejemplo 2: En este ejemplo, estaremos trazando múltiples Y con varios otros parámetros.

# importing the modules 
from bokeh.plotting import figure, output_file, show 
   
# file to save the model 
output_file("gfg.html") 
        
# instantiating the figure object 
graph = figure(title = "Bokeh Y Graph") 
   
# name of the x-axis 
graph.xaxis.axis_label = "x-axis"
        
# name of the y-axis 
graph.yaxis.axis_label = "y-axis"
   
# points to be plotted
x = [3, 3, 5]
y = [3, 1, 3]
size = [130, 100, 60]
   
# color value of the Ys
color = ["yellow", "red", "purple"]
   
# fill alpha value of the Ys
fill_alpha = [0.9, 0.7, 0.5]
  
# line width of the Ys
line_width = [10, 15, 5]
  
# plotting the graph 
graph.y(x, y,
        size = size,
        color = color,
        fill_alpha = fill_alpha,
        line_width = line_width) 
        
# displaying the model 
show(graph)

Producción :

Publicación traducida automáticamente

Artículo escrito por Yash_R y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *