title: how to save a QuanFig obj to png or jpeg file
body: <p>I am trying to save my Qantfig object to a png file and it does not work.
  Here is the function that is creating the QuantFig object and then formatting it.
  At the end of the function I try to dump it to a file using Pickle.
  But I get an error (an empty png file gets created under the images folder).</p>
  <pre><code> def plot_prices(self,startdate,enddate,trendstart,trendend,chart_type = &quot;default&quot;,macd=False,rsi=False,
                  volume=False,bands=False,trend=False):
      if(chart_type == &quot;default&quot;):
          qf = cf.QuantFig(df = self.data.loc[startdate:enddate])
          if (volume == True):
              qf.add_volume(colorchange=True)
          if (bands == True):
              qf.add_bollinger_bands(periods = 20, boll_std=2)
          if (macd == True):
              qf.add_macd()
          if(rsi == True):
              qf.add_rsi()
          if(trend == True):
              qf.add_trendline(date0 = trendstart,date1 = trendend)
          qf.iplot(title = &quot;Close Price chart of {ticker}&quot;.format(ticker = self.ticker),
                          xTitle = &quot;{ticker}&quot;.format(ticker = self.ticker),
                          yTitle = &quot;Stock Price&quot;)
          if not os.path.exists(&quot;images&quot;):
              os.mkdir(&quot;images&quot;)
          filehandler = open(&quot;images/{}.png&quot;.format(self.ticker), 'w') 
          pickle.dump(qf, filehandler)
  </code></pre>
  <p>it gives me the error</p>
  <pre><code>TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-3-8299d27512fc&gt; in &lt;module&gt;
  ----&gt; 1 stock.plot_prices(StartDate,Today,&quot;2021-07-09&quot;,&quot;2021-12-31&quot;,&quot;candle&quot;,
        2                   macd=False,rsi=True,volume=True,bands=True,trend=False)
  
  ~\Jupyter\Algo_Trading\ClassLib\Visualization.py in plot_prices(self, startdate, enddate, trendstart, trendend, chart_type, macd, rsi, volume, bands, trend)
       65                 os.mkdir(&quot;images&quot;)
       66             filehandler = open(&quot;images/{}.png&quot;.format(self.ticker), 'w')
  ---&gt; 67             pickle.dump(qf, filehandler)
       68 
       69     def plot_returns(self,kind = &quot;ts&quot;):
  
  TypeError: write() argument must be str, not bytes
  </code></pre>
  <p>Can someone help me with this code, I am not sure if there is any other way to dump a QuantFig to a png object. I have tried Pickle and it does not seem to help.
  are there other ways to do this.</p>