I created the following df that contains the following data:
True Price Range
0 0.3151260504201625
1 0.08403361344537472
2 0.3577441077441151
3 0.2773629187113253
4 0.1715633712202524
5 0.4948364888123946
6 0.30068728522337035
7 0.043261951113993474
8 0.4562242016076512
9 0.1527050610820258
10 0.2185314685314596
11 0.9452626950978232
12 0.459016393442627
13 0.48097944905989937
14 0.17459624618071515
15 0.39534372940917983
16 0.44130626654898236
17 0.440237728373319
18 0.4386926957666129
19 0.4149377593361054
20 0.08748906386702823
21 0.21920210434019272
22 6.046511627906989
23 0.1536772777167961
24 0.06590509666081337
25 0.021987686895345346
26 0.46337157987643834
27 0.3077599472411393
28 0.043907793633368136
29 0.17644464049405312
30 0.29082774049218146
31 0.3157419936851629
32 0.49762497172584935
33 0.24797114517584748
34 0.49571879224875615
35 0.2941842045711658
36 0.49661399548532276
37 0.6515389800044902
38 0.4916201117318546
39 0.6037567084078699
40 1.1599375418246702
41 0.2668445630420171
42 0.28882470562096907
43 0.3771073646849967
44 0.17742293191395805
45 0.022158209616654382
46 0.46532240194991115
47 0.3576218149307117
48 0.15642458100558798
49 0.27008777852802623
50 0.3161698283649531
51 0.18289894833103962
52 0.7097069597069705
53 0.5325306783977797
54 0.13879250520472936
55 0.3940658321743243
56 0.1391465677180067
57 0.301694128568109
58 0.1860897883228582
59 0.1638193306810218
I'm trying to plot its corresponding boxplot, based on this guide, I can run df["True Price Range"].plot(kind='box', title='Boxplot of True Price Range') in the Spyder console to get that.
But after doing so, I get the following output:
Out[3]: <pyqtgraph.graphicsItems.PlotDataItem.PlotDataItem at 0x1dc1a1bf670>
Which I don't understand, I also tried:
df["True Price Range"].plot(kind='box', title='Boxplot of True Price Range').show()
And got literally nothing as output, not even errors.
Finally I tried using the Pandas boxplot function (i.e. df.boxplot(column= "True Price Range")) and got the following error:
AttributeError: module 'finplot.pdplot' has no attribute 'boxplot_frame'
Note: Both matplotlib.pyplot and pandas libraries were imported as pd and plt respectively before running the syntax above
May I get some assistance here?
Regarding your first command, the output you get is simply the object type that you have created (pyqtgraph.graphicsItems.PlotDataItem.PlotDataItem) and the memory address where this object is located (0x1dc1a1bf670). There is nothing wrong with this output. If you want to see the plot, you should add plt.show() after this command. Therefore, the code should be:
df["True Price Range"].plot(kind='box', title='Boxplot of True Price Range')
plt.show() # displays the figure
The matplotlib.pyplot.show function displays the figure that you have created.
Regarding the line df["True Price Range"].plot(kind='box', title='Boxplot of True Price Range').show(), you shouldn't call the show method on the object you have just created (i.e., the pyqtgraph.graphicsItems.PlotDataItem.PlotDataItem type). Just call the show method as mentioned above.
Regarding the AttributeError you mention last, it means that the method you want to call does not exist.
Solved by running the following lines:
plt.boxplot(x=df, vert = False)
plt.show() # displays the figure
matplotlib.pyplot must have been imported as plt
I need to make a diagram which shows the lines of different ceramic firing schedules. I want them to be plotted in one diagram and they need to be plotted in time-relative ax. It needs to show the different durations in a right way. I don't seem to be able to achieve this.
What I have is the following:
First table:
Pendelen
Temp. per uur
Stooktemp.
Stooktijd 4
Stooktijd Cum.4
95
120
1:15:47
1,26
205
537
2:02:03
3,30
80
620
1:02:15
4,33
150
1075
3:02:00
7,37
50
1196
2:25:12
9,79
10
1196
0:10:00
9,95
Total
9:57:17
Second table:
Pendelen
Temp. per uur
Stooktemp.
Stooktijd 5
Stooktijd Cum.5
140
540
3:51:26
3,86
65
650
1:41:32
5,55
140
1095
3:10:43
8,73
50
1222
2:32:24
11,27
Total
11:16:05
The lines to be shown in a diagram should represent the 'stooktijd cum.' for both programs 4 and 5 (which is a cumulation of the time needed to fire up the kiln from it's previous temp. in the schedule). One should be able to see in the diagram that program 5 takes more time to reach it's endtemp.
What I achieved is nothing more than a diagram with two lines, but only plotted in the 'stooktijd cum.4' points from program 4. The image shows a screenshot of this diagram.
But as you can see, this doesn't look like program 5 takes more time to reach it's end. I would like it to show something like this:
Create this table :
p4
p5
0
10
3.86
540
5.55
650
8.73
1095
11.27
1222
0
0
1.26
120
3.3
537
4.33
620
7.37
1075
9.79
1196
9.95
1196
Select all > F11 > Design > Chg Chart type > scatter with straight line and marker
Here's my tryout :
Please share if it works/not. ( :
I'm trying to plot some experimental data using gnuplot and I need to include data uncertainty in tics' labels. I've figured out that I can manually change every label to "200.0" from "200", but I'm almost sure that there is an easier method. I do hope for your help. :)
Your question is a bit unclear. I understand it like this
$data <<EOD
120 20 250 30
160 20 190 40
200 30 300 23
280 15 260 15
340 25 190 40
EOD
plot $data us 1:3:4:xtic(sprintf("%.1f +/- %.1f", $1, $2)) w err pt 7
See help xticlabel (in contrast to xtics).
everyone! So I have 2 dataframes extracted from Pro-Football-Reference as a csv and run through Pandas with the aid of StringIO.
I'm pasting only the header and a row of the info right below:
data_1999 = StringIO("""Tm,W,L,W-L%,PF,PA,PD,MoV,SoS,SRS,OSRS,DSRS Indianapolis Colts,13,3,.813,423,333,90,5.6,0.5,6.1,6.6,-0.5""")
data = StringIO("""Tm,W,L,T,WL%,PF,PA,PD,MoV,SoS,SRS,OSRS,DSRS Indianapolis Colts,10,6,0,.625,433,344,89,5.6,-2.2,3.4,3.9,-0.6""")
And then interpreted normally using pandas.read_csv, creating 2 different dataframes called df_nfl_1999 and df_nfl respectively.
So I was trying to use Bokeh and do something like here, except instead of 'apples' and 'pears' would be the name of the teams being the main grouping. I tried to emulate it by using only Pandas Dataframe info:
p9=figure(title='Comparison 1999 x 2018',background_fill_color='#efefef',x_range=df_nfl_1999['Tm'])
p9.xaxis.axis_label = 'Team'
p9.yaxis.axis_label = 'Variable'
p9.vbar(x=dodge(df_nfl_1999['Tm'],0.0,range=p9.x_range),top=df_nfl_1999['PF'],legend='PF in 1999', width=0.3)
p9.vbar(x=dodge(df_nfl_1999['Tm'],0.25,range=p9.x_range),top=df_nfl['PF'],legend='PF in 2018', width=0.3, color='#A6CEE3')
show(p9)
And the error I got was:
ValueError: expected an element of either String, Dict(Enum('expr',
'field', 'value', 'transform'), Either(String, Instance(Transform),
Instance(Expression), Float)) or Float, got {'field': 0
Washington Redskins
My initial idea was to group by Team Name (df_nfl['Tm']), analyzing the points in favor in each year (so df_nfl['PF'] for 2018 and df_nfl_1999['PF'] for 1999). A simple offset of the columns could resolve, but I can't seem to find a way to do this, other than the dodge chart, and it's not really working (I'm a newbie).
By the way, the error reference is appointed at happening on the:
p9.vbar(x=dodge(df_nfl_1999['Tm'],0.0,range=p9.x_range),top=df_nfl_1999['PF'],legend='PF in 1999', width=0.3)
I could use a scatter plot, for example, and both charts would coexist, and in some cases overlap (if the data is the same), but I was really aiming at plotting it side by side. The other answers related to the subject usually have older versions of Bokeh with deprecated functions.
Any way I can solve this? Thanks!
Edit:
Here is the .head() method. The other one will return exactly the same categories, columns and rows, except that obviously the data changes since it's from a different season.
Tm W L W-L% PF PA PD MoV SoS SRS OSRS \
0 Washington Redskins 10 6 0.625 443 377 66 4.1 -1.3 2.9 6.8
1 Dallas Cowboys 8 8 0.500 352 276 76 4.8 -1.6 3.1 -0.3
2 New York Giants 7 9 0.438 299 358 -59 -3.7 0.7 -3.0 -1.8
3 Arizona Cardinals 6 10 0.375 245 382 -137 -8.6 -0.2 -8.8 -5.5
4 Philadelphia Eagles 5 11 0.313 272 357 -85 -5.3 1.1 -4.2 -3.3
DSRS
0 -3.9
1 3.4
2 -1.2
3 -3.2
4 -0.9
And the value of executing just x=dodge returns:
dodge() missing 1 required positional argument: 'value'
By adding that argumento value=0.0 or value=0.2 the error returned is the same as the original post.
The first argument to dodge should a single column name of a column in a ColumnDataSource. The effect is then that any values from that column are dodged by the specified amount when used as coordinates.
You are trying to pass the contents of a column, which is is not expected. It's hard to say for sure without complete code to test, but you most likely want
x=dodge('Tm', ...)
However, you will also need to actually use an explicit Bokeh ColumnDataSource and pass that as source to vbar as is done in the example you link. You can construct one explicitly, but often times you can also just pass the dataframe directly source=df, and it will be adapted.
I want to create this typ of chart in excel:
With the vertical gridlines dividing the chart by year, and the labels for each year. The guy who made this chart said he thinks he just drew in the lines and added the labels manually somehow. But can this be done any other way? drawing lines in charts isnt very exact and the only other solutions i've found can't really produce the same result.
If you have data that looks something like:
Jan-14 4
Feb-14 30
Mar-14 56
Apr-14 23
May-14 3
Jun-14 62
Jul-14 74
Aug-14 12
Sep-14 3
Oct-14 15
Nov-14 63
Dec-14 74
Jan-15 45
Feb-15 3
Mar-15 4
Apr-15 56
May-15 23
Jun-15 3
Jul-15 62
Aug-15 74
Sep-15 12
Oct-15 3
Nov-15 15
Dec-15 63
Jan-16 74
You can select that data and add a new scatter plot style chart. It will, by default, look very similar to the one above. To get vertical lines at the years, you can right-click the x-axis and choose "Format Axis". Click "Fixed" for the "Major Unit" and enter 356 as the number.
Right click again on the x-axis and choose "Add Major Gridlines". You should get a vertical line for each year.
As for the boxes/labels with the years, you may have to do that manually or get creative with VBA.