1

I get two different results when I use bokehs circle (ordiamond_cross` function) and line function. The line function includes negative values and the circle does not.

Plot with line enter image description here and a plot with diamond_cross enter image description here

I want to plot the temperatures for a certain place over a timespan. I have a lot of values therefore I would like to make a scatterplot through bokeh.

I also get the same problem when I use the x function.

In my code below you can change the diamond_cross with line and remove the fill_alpha and size then you will probably also get two different graphs.

import pandas as pd
import numpy as np
import bokeh as bk
import scipy.special

from bokeh.plotting import figure, output_file, show
from bokeh.models import ColumnDataSource
from bokeh.models.tools import HoverTool
from bokeh.models.glyphs import Quad
from bokeh.layouts import gridplot


df = pd.read_csv('KNMI2.csv', sep=';',
                    usecols= ['YYYYMMDD','Techt', 'YYYY', 'MM', 'D'])


jan= df[df['MM'].isin(['1'])]

source_jan = ColumnDataSource(jan)


p = figure(plot_width = 800, plot_height = 800,
           x_range=(0,32), y_range=(-20,20))
p.diamond_cross(x='D', y='Techt', source=source_jan,
         fill_alpha=0.2, size=2)
p.title.text = 'Temperatuur per uur vanaf 1951 tot 2019'
p.xaxis.axis_label = 'januari'
p.yaxis.axis_label = 'Temperatuur (C)'
show(p)

If both the circle/ diamond_cross function work the same as the line function then their plots will also show negative values.

galfisher
  • 1,122
  • 1
  • 13
  • 24
keesnotels
  • 11
  • 1

1 Answers1

0

I had a similar issue where the the data type of the variable I was trying to plot was string instead of int.

Try using

jan = df[df['MM'].isin(['1'])]
jan['Techt'] = jan['Techt'].astype(int)
source_jan = ColumnDataSource(jan)
Robert
  • 1
  • 1