Существует ли универсальный способ увеличения размера диаграммы matplotlib Python в Jupyter?

#python #matplotlib #pyalgotrade

Вопрос:

Я обнаружил, что различные пакеты не позволяют использовать plt.figure(figsize=(12,10)) и устанавливать значения по умолчанию размер рисунка на очень низком уровне. Я столкнулся с этой проблемой, например, в pyalgotrade модуле:

Итак, вопрос в том, как увеличить размер диаграммы более универсальным способом в Jupyter и конкретно в pyalgotrade plotter ?

Размер диаграммы по умолчанию pyalgotrade очень мал:

 from pyalgotrade import plotter
from pyalgotrade.barfeed import quandlfeed
from pyalgotrade.stratanalyzer import returns
import sma_crossover

# Load the bar feed from the CSV file
feed = quandlfeed.Feed()
feed.addBarsFromCSV("orcl", "WIKI-ORCL-2000-quandl.csv")

# Evaluate the strategy with the feed's bars.
myStrategy = sma_crossover.SMACrossOver(feed, "orcl", 20)

# Attach a returns analyzers to the strategy.
returnsAnalyzer = returns.Returns()
myStrategy.attachAnalyzer(returnsAnalyzer)

# Attach the plotter to the strategy.
plt = plotter.StrategyPlotter(myStrategy)
# Include the SMA in the instrument's subplot to get it displayed along with the closing prices.
plt.getInstrumentSubplot("orcl").addDataSeries("SMA", myStrategy.getSMA())
# Plot the simple returns on each bar.
plt.getOrCreateSubplot("returns").addDataSeries("Simple returns", returnsAnalyzer.getReturns())

# Run the strategy.
myStrategy.run()
myStrategy.info("Final portfolio value: $%.2f" % myStrategy.getResult())

# Plot the strategy.
plt.plot()
 

учебник по pyalgotrade

Комментарии:

1. вы можете попробовать увеличить figure.dpi настройку в своем matplotlibrc файле, так как это также влияет на размер цифр, отображаемых в записной книжке Jupiter

2. plt.rcParams['figure.figsize'] = (16.0, 10.0)