想要在 Beamer 类上运行图表

想要在 Beamer 类上运行图表

之前我在 \documentclass{article} 中运行了关于图表的程序代码,成功了。但是,当我将其更改为 \documentclass{beamer} 并在文本中添加 \begin{frame} ...content... \end{frame} 时,问题就来了。有谁知道如何解决这个问题。这是我的图表代码:

   \documentclass{beamer}
   \usepackage[margin=0.5in]{geometry}
   \usepackage[utf8]{inputenc}
   \usepackage{textcomp}

   \usepackage{pgfplots}
   \pgfplotsset{width=10cm,compat=1.9}

   \begin{document}

  \begin{frame}

   \begin{tikzpicture}
   \begin{axis}[
    title={},
    xlabel={Shape parameter},
    ylabel={Confidence Interval for location parameter},
    xmin=-3.5, xmax=1.5,
    ymin=0, ymax=10.5,
    xtick={-3,-2,-1,0,1},
    ytick={4,6,8,10},
    legend pos=north west,
    ymajorgrids=true,
    grid style=dashed,
     ]

    \addplot [
     color=red,
     ]
     coordinates {(-3,9.079491)(-2.5,9.452603)(-2,9.777221)(-1.9,9.766175)                    
     (-1.8,9.919383)(-1.7,9.968541)(-1.6,10.033590)(-1.5,10.091473)(-1.4,10.058541)             
     (-1.3,10.227247)(-1.2,10.16644)(-1.1,10.229299)(-1.0,10.192760)(-0.9,10.192760)             
     (-0.8,10.241929)(-0.7,10.216065)(-0.6,10.227887)(-0.5,10.186640)(-0.4,10.169810)   
     (-0.3,10.258170)(-0.2,10.250998)(-0.1,10.19826)(0.2,10.209682)(0.4,10.193243)  
     (0.6,10.205120)(0.8,10.184040)(1.0,10.247810)};

    \addplot[
    color=blue,
     ]
     coordinates{(-3,2.859848)(-2.5,6.456956)(-2.0,7.751660)(-1.9,8.111291)          
     (-1.8,8.394369)(-1.7,8.534462)(-1.6,8.775830)(-1.5,9.011516)(-1.4,9.098876)
      (-1.3,9.286731)       
     (-1.2,9.257532)(-1.1,9.407769)(-1.0,9.688250)(-0.9,9.735059)(-0.8,9.814046)       
     (-0.7,9.780176)(-0.6,9.814046)(-0.5,9.800660)(-0.4,9.768130)(-0.3,9.818090)
     (-0.2,9.831134)(-0.1,9.772771)  (0.2,9.772683)(0.4,9.795465)(0.6,9.745820)
     (0.8,9.830740)(1.0,9.819173)};


    \end{axis}
    \end{tikzpicture}

    \end{frame}

相关内容