Aug-16-2019, 07:07 PM
Dear community,
This subject as already been asked on the net but in my case my problem seems to be slightly different. I'm trying to draw a line using matplotlib with a specific lenght (400mm) and a specific thickness (4mm). I managed to draw a line with the desired lenght but I didn't find a way to add a specific thickness to this line. I tried to use the linewidth parameter but my result is not accurate. For now the thickness is closed to 5.38mm instead of 4mm. I'm saving my plot in a svg type in order to use inkscape to control the real length and thickness of my line.
Thanks a lot for helping me !
This subject as already been asked on the net but in my case my problem seems to be slightly different. I'm trying to draw a line using matplotlib with a specific lenght (400mm) and a specific thickness (4mm). I managed to draw a line with the desired lenght but I didn't find a way to add a specific thickness to this line. I tried to use the linewidth parameter but my result is not accurate. For now the thickness is closed to 5.38mm instead of 4mm. I'm saving my plot in a svg type in order to use inkscape to control the real length and thickness of my line.
Thanks a lot for helping me !
import matplotlib.pyplot as plt fig1 = plt.figure(figsize=(400/25.4,400/25.4))#size in inches ax1= plt.gca() ax1.set_ylim(0,400) ax1.set_xlim(0,400) ax1.set_xticklabels([]) ax1.set_yticklabels([]) ax1.axis('off') fig1.tight_layout() x = [0,400] y = [200,200] ax1.plot(x,y,linewidth=4*1574.8/400)#with 100dpi the figure should be 1574.8px*1574.8px plt.subplots_adjust(left=0, right=1, top=1, bottom=0) plt.savefig('test.svg', bbox_inches='tight', pad_inches=0, dpi='figure')