I'm using PyLaTeX to generate automatically a report file. This report is to be filled with matplotlib plots and I want them to be placed exactly where the code says so. Usually in Latex, I would use the [h] suffix or even [H], but here, no matter what I put in the position, it doesn't work (I mean that the plots are not placed where I want).
Here's my code:
from pylatex import Document, Section, Subsection, Command, Figure
from pylatex.utils import italic, bold, NoEscape
import matplotlib.pyplot as plt
plt.style.use('ggplot')
import numpy as np
x = np.linspace(-np.pi/2, np.pi/2,100)
y = np.sin(x)
plt.plot(x,y)
doc = Document('Test')
doc.preamble.append(Command('title', 'Test PyLaTex'))
doc.preamble.append(Command('author', 'Mehdi'))
doc.preamble.append(Command('date', NoEscape(r'\today')))
doc.append(NoEscape(r'\maketitle'))
with doc.create(Section('Premiere Section')):
doc.append('Premiers resultats \n')
doc.append('Second resultats')
with doc.create(Section('Deuxieme section')):
doc.append('Premiers res 2')
with doc.create(Figure(position = 'htbp')) as fig:
fig.add_image('m.jpg')
fig.add_caption('Celui qui a tout fait')
with doc.create(Figure(position = 'htbp')) as plot:
plot.add_plot()
plot.add_caption('Avec matplolib')
with doc.create(Section('Troisieme')):
doc.append('test image position')
with doc.create(Section('Conclusion')):
doc.append('Iz practical')
doc.generate_pdf(clean_tex = False)
doc.generate_tex()
Thanks !