如何使用matplotlib在图形图旁边绘制表格?

时间:2019-08-19 13:58:55

标签: matplotlib jupyter-notebook ipython

我需要使用Jupyter Notebook将Mathematica代码转换为IPython。该代码生成一个时间序列图和一个不规则形状的表格,汇总了有关数据的一些统计信息。

我不认为matplotlib.pyplot.table可用于此目的,因为表格未与图形绘图的轴对齐。 可以使用Pandas数据框完成此操作吗?

这是Mathematica代码:

summary = gr[Join[{
     {"", Style["Raw", Lighter@Red], Style["Treated", Lighter@Blue]},
     {"Mean", pf2@mc1, pf2@mc2},
     {"95%", pf2@p951, pf2@p952},
     {"Gamma \[Alpha]", pf2[mc1/b1], pf2[mc2/b2]},
     {"Gamma \[Beta]", pf2@b1, pf2@b2}
     }, If[Length@sel == 0, {{}},
     msel = Mean@sel[[All, 2]];
     p95sel = Quantile[sel[[All, 2]], .95];
     bobs = gb[msel, p95sel];
     begin = Flatten@{sel[[1, 1, 1]][[;; 2]], 1}; 
     d = Table[
       DateDifference[begin, sel[[i, 1, 1]]][[1]], {i, Length@sel}];
     r2 = 
      1 - Total[(sel[[All, 2]] - c[[2, d]])^2]/
        Total[(sel[[All, 2]] - msel)^2];
     {{"\[EmptyCircle] Data " <> lblmo <> " (+non detects)", spl},
      {"Mean", pf2@msel}, {"95%", pf2@p95sel},
      {"Gamma \[Alpha]", pf2[msel/bobs]}, {"Gamma \[Beta]", 
       pf2@bobs}, {"\!\(\*SuperscriptBox[\(R\), \(2\)]\)", pf2@r2}}]]];
clst = {Thread[{days, c[[1]]}], Thread[{days, c[[2]]}]};
fig = If[cscale == 1, DateListPlot, DateListLogPlot][
   If[Length@sel == 0, clst, Join[clst, dmdata@sel]],
   DateTicksFormat -> {"MonthNameInitial"}, PlotRange -> All, 
   Joined -> {True, True, False}, RotateLabel -> False,
   FrameLabel -> {{"#/L", summary}, {None, wwtp <> "-" <> mo}}, 
   PlotStyle -> {Lighter@Red, Lighter@Blue, Black},
   PlotMarkers -> {, , "\[EmptyCircle]"}, lblst[fs], ImageSize -> is];

0 个答案:

没有答案