Backtrader Community

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Basic Plotting - No X Axis

    General Code/Help
    4
    6
    2185
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      rluc99 last edited by

      Hi fellow backtraders!
      I have just started familiarizing myself with Backtrader. I have a newbie question for you:
      Using the examples in the Quickstart guide I got to the section on plotting.
      https://www.backtrader.com/docu/quickstart/quickstart/#visual-inspection-plotting
      I copied the code exactly and got an identical plot except the x axis (date) is not showing at all. The cursor gives the right dates but there is no text on the axis. What have I forgotten?!
      Thanks
      (PS: Also, is there a place in Backtrader Community for newbies like me to look at first to find the usual gotchas.)

      1 Reply Last reply Reply Quote 3
      • Pablo Reyes Almagro
        Pablo Reyes Almagro last edited by

        I just wanted to ask the same thing. Good to know I'm not alone!

        1 Reply Last reply Reply Quote 0
        • B
          backtrader administrators last edited by backtrader

          The x-axis is there (luckily, because if not everything would be displayed on a singularity rim and we should fear a potential earth implosion into such an event) but the x-ticks (i.e: timestamps in this case) are not displayed in the latest latest version of matplotlib (currently 3.1.1)

          The previous stable version 3.0.3 and the last LTS version 2.2.4 do display the x-ticks.

          pip install --force matplotlib==YOUR-PREFERRED-WORKING-VERSION
          
          R Pablo Reyes Almagro 2 Replies Last reply Reply Quote 4
          • R
            rluc99 @backtrader last edited by

            @backtrader Thanks for the rapid reply - it works! Life is good. The universe is back in equilibrium

            1 Reply Last reply Reply Quote 0
            • Pablo Reyes Almagro
              Pablo Reyes Almagro @backtrader last edited by

              @backtrader Awesome, that fixed it!

              1 Reply Last reply Reply Quote 0
              • A
                Aritz Lizaso last edited by

                Hi, i need some help please. I tried to install matplotlib as you say but now i cant run the plot. i tried to change versions, reinstall anoaconda but now always have the same error and i cant show the plots as always. It give me this error:


                TypeError Traceback (most recent call last)
                <ipython-input-8-cf679b847698> in <module>
                1 # cerebro.plot(start=datetime.date(2005, 7, 1), end=datetime.date(2006, 1, 31))
                2
                ----> 3 fig = cerebro.plot(style='candle', numfigs=1, barup ='gold', bardown ='darkgoldenrod', valuetags=False, rowsmajor=5, rowsminor=2, plotdist=0.1)[0][0]
                4 fig.savefig('example.png', dpi=400)
                5 #figure = cerebro.plot(style ='candlebars')[0][0]

                ~\Anaconda3\lib\site-packages\backtrader\cerebro.py in plot(self, plotter, numfigs, iplot, start, end, width, height, dpi, tight, use, **kwargs)
                972
                973 if not plotter:
                --> 974 from . import plot
                975 if self.p.oldsync:
                976 plotter = plot.Plot_OldSync(**kwargs)

                ~\Anaconda3\lib\site-packages\backtrader\plot_init_.py in <module>
                31
                32
                ---> 33 from .plot import Plot, Plot_OldSync
                34 from .scheme import PlotScheme

                ~\Anaconda3\lib\site-packages\backtrader\plot\plot.py in <module>
                33 import numpy as np # guaranteed by matplotlib
                34 import matplotlib.dates as mdates
                ---> 35 import matplotlib.font_manager as mfontmgr
                36 import matplotlib.legend as mlegend
                37 import matplotlib.ticker as mticker

                ~\AppData\Roaming\Python\Python37\site-packages\matplotlib\font_manager.py in <module>
                46
                47 import matplotlib as mpl
                ---> 48 from matplotlib import afm, cbook, ft2font, rcParams, get_cachedir
                49 from matplotlib.fontconfig_pattern import (
                50 parse_fontconfig_pattern, generate_fontconfig_pattern)

                ~\AppData\Roaming\Python\Python37\site-packages\matplotlib\afm.py in <module>
                358
                359
                --> 360 @deprecated("3.0", "Use the class AFM instead.")
                361 def parse_afm(fh):
                362 return _parse_afm(fh)

                TypeError: deprecated() takes 1 positional argument but 2 were given

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors