Home > other >  Pandas matplotlib line chart for help
Pandas matplotlib line chart for help

Time:10-10

The following code generation as shown in figure, but there are a few problems need to be improved, and help you a great god, first thanked,
1. The abscissa scale to date
2. Data points from discontinuous to continuous, groupby after not concat,




 # coding=utf-8 
# Zhoubin 2019-11-16

Import pandas as pd # data processing and analysis of library
The import # OS operating system OS
Import matplotlib. # pyplot as PLT visual chart
The from matplotlib. Pyplot import MultipleLocator # coordinates calibration
Import numpy as np # scientific computing library

Drawing=input (' input drawing no. :)
XLS=pd. ExcelFile (r 'd: \ python \ grinding at the end of the first pieces in each process. XLSM') # read excel data
Source=pd. Read_excel (XLS, sheet_name='target', the header=None, engine='c', the index=None) # # drawings=source [0]. Drop_duplicates (inplace=True) to remove duplicate values
Source. The drop (,3,4,5,6,8 [1], the axis=1, inplace=True) # delete unwanted columns
Source. The drop (source [source [0]!=drawing]. Index, inplace=True) # to delete A column is not equal to line drawing is
='any' source. Dropna (how), copy () # delete empty value
Source. The drop (source [source [7]=='inspection frequency/time]. Index, inplace=True) # remove "check frequency/time" row of
Gp=source. Groupby (by=[7], sort=True) # grouping by check content
Length=len (gp) # check content item number # source. Set_index ([2], inplace=True, the drop=False) # by date index
I=0
FIG, ax=PLT. Subplots (nrows=length, ncols=1, sharex=True, figsize=(11.5, 8.2)) # define subgraph quantity, share the X axis coordinate
Try:
Ax [0]. Set_title (' {} 'Xbar -r control chart. The format (drawing), 18) fontsize=# define title
Except:
Print (' initialize title failure)

For k, v in gp:
Print (v)
Ax [I] the plot (v.i loc [:, 3:], graphics.linestyle=':' our linewidth=1.2, marker='. ', markersize=4)
Ax [I] set_xlabel (written by k.r eplace (' \ n ', '), weight='normal', fontsize=10) # label font size, remove the newline # ax [I] yaxis. Set_ticks_position (' left ') # ax [I] yaxis. Set_major_locator (y_major_locator)
Ax [I]. The grid (True, alpha=0.5)
I=I + 1

PLT. RcParams [' font. Sans-serif]=[' SimHei] # # Chinese support PLT. RcParams ['. The font size]=6
PLT. Tight_layout ()
PLT. Subplots_adjust (=0.07, left=0.06, bottom right=0.97, top=0.94, img tags like hspace=0.2, wspace=0.15) # # to adjust the margins, subgraph spacing
PLT. Savefig (r 'PDF' d: \ python \ {}. The format (drawing) # save as PDF document
PLT. The show ()


Target content as follows, not attachment, can you teach me? Thank you
27577 21806 fine grinding night shift work days song-lin zhang MU 2019-09-18-07 MU - 20190918-07 inspection frequency/time Y art art art art art art art art art
27577 21806 fine grinding night shift work days song-lin zhang MU 2019-09-18-07 MU - 20190918-07 "to the outer diameter? 7.992 +/- 0.002) ∷
The target value of (+/- 0.001 "Y 7.993 7.993
27577 21806 fine grinding night shift work days song-lin zhang MU 2019-09-18-07 MU - 20190918-07 diameter roughness Rz0.5 2.5 0.7 0.6 0.7 0.7 MAX Y
27577 21806 fine grinding night shift work days song-lin zhang MU 2019-09-18-07 MU roundness MAX 0.0015 Y - 20190918-07 diameter 0.001 0.0011 0.001 0.001
27577 21806 fine grinding night shift work days song-lin zhang MU 2019-09-18-07 MU - 20190918-07 middle diameter to beat 0.03 MAX Y 0.01
27577 21865 coarse grinding the night shift work days Li Haodong 2019-09-18 MU - 10 MU - 20190918-10 inspection frequency/time when Y when
27577, 21865, coarse grinding the 2019-09-18 night shift work days Li Haodong MU - 10 MU - 20190918-10 outside diameter? 8.070 +/- 0.008 8.06 8.072 Y
27577 22051 fine grinding the 2019-09-18 night shift work days Xie Xuwei 15 MU MU - Y - 20190918-15 inspection frequency/time when
27577 22051 fine grinding the 2019-09-18 night shift work days Xie Xuwei MU - 15 MU - 20190918-15 outer diameter? 7.992 +/- 0.002 ∷ Y 7.992
27577 22051 fine grinding the 2019-09-18 night shift work days Xie Xuwei MU - 15 MU - 20190918-15 diameter roughness Rz2.5 MAX 2.4 Y
27577 22051 fine grinding the 2019-09-18 night shift work days Xie Xuwei MU - 15 MU - 20190918-15 roundness 0.0015 MAX Y 0.001
27577 22051 fine grinding the 2019-09-18 night shift work days Xie Xuwei MU - 15 MU - 20190918-15 middle diameter to beat 0.03 MAX Y 0.01
27577 22051 fine grinding the 2019-09-18 night shift work days Xie Xuwei 15 MU MU - beating MAX 0.03 Y - 20190918-15 small diameter 0.02
27577, 26012, coarse grinding the 2019-09-18 day day shift people MS - 06 MS - 20190918-06 at 8:10 inspection frequency/time Y
27577, 26012, coarse grinding the 2019-09-18 day day shift people MS - 06 MS - 20190918-06 to the outer diameter? 8.02 + 0/0.01 ∷ Y 8.01
1101-3070012 fine grinding the 2019-09-18 day day Li Haodong MU - 17 MU - 20190918-17 inspection frequency/time Y 8:20
1101-3070012 fine grinding the 2019-09-18 day day Li Haodong MU - 17 MU - 20190918-17 "in the second period of fine grinding diameter
? 8.0 ~ 8.005 8.004
"Y1101-3070012 coarse grinding the 2019-09-18 day day Jane forward MU - 08 MU - 20190918-08 inspection frequency/time Y 8:23
1101-3070012 coarse grinding the 2019-09-18 day day Jane forward MU - 08 MU - 20190918-08 "in the second period of coarse grinding diameter
? 8.025 -? 8.035 "Y 8.028
1101-1140206 hanging mill 1 2019-09-18 day day QinWen law of MU - 19 MU - 20190918-19 inspection frequency/time Y for
1101-1140206 hanging mill 1 2019-09-18 day day QinWen law of MU - 19 MU - 20190918-19 "second, four outer diameter
? 10.02 10.03 ∷ "Y 10.025
1101-1140206 hanging mill 2 2019-09-18 day day QinWen law of MU - 19 MU - 20190918-19 inspection frequency/time Y 14:45
1101-1140206 hanging mill 2 2019-09-18 day day QinWen law of MU - 19 MU - 20190918-19 "second, four outer diameter
? 10.0 + 0.007 +/0.003 ∷ "Y 10.006
1101-1140206 hanging mill 2 2019-09-18 day day QinWen law of MU - 19 MU - 20190918-19 inspection frequency/time Y oh
1101-1140206 hanging mill 2 2019-09-18 day day QinWen law of MU - 19 MU - 20190918-19 "second, four outer diameter
? 10.0 + 0.007 +/0.003 ∷ "Y 10.005
1101-1140206 hanging mill 2 2019-09-18 day day WeiYongXuan MU - 19 MU - 20190918-19 inspection frequency/time Y all
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related