I used the code from this thread to generate candle-stick charts on stock prices. The code hides the axis and everything is just fine.
plt.figure()
width = 1
width2 = 0.1
pricesup = df[df.close >= df.open]
pricesdown = df[df.close < df.open]
plt.bar(pricesup.index, pricesup.close - pricesup.open, width, bottom=pricesup.open, color='g')
plt.bar(pricesup.index, pricesup.high - pricesup.close, width2, bottom=pricesup.close, color='g')
plt.bar(pricesup.index, pricesup.low - pricesup.open, width2, bottom=pricesup.open, color='g')
plt.bar(pricesdown.index, pricesdown.close - pricesdown.open, width, bottom=pricesdown.open, color='r')
plt.bar(pricesdown.index, pricesdown.high - pricesdown.open, width2, bottom=pricesdown.open, color='r')
plt.bar(pricesdown.index, pricesdown.low - pricesdown.close, width2, bottom=pricesdown.close, color='r')
plt.gca().set_axis_off()
plt.subplots_adjust(
top=1,
bottom=0,
right=1,
left=0,
hspace=0,
wspace=0
)
plt.margins(0, 0)
plt.savefig(file_path, bbox_inches='tight', format=file_format, dpi=72)
But when I load the image using TensorFlow decode_png method, it shows the hidden axis:
image = tf.io.read_file('test.png')
image = tf.io.decode_png(image)
plt.imshow(image)
plt.show()
Image loaded through windows Photo:
Image loaded in Pythin with TensorFlow library:
This is not showing the hidden axis, your image is properly saved without the first axis. But plt.imshow()
is creating and showing a new axis when you open the image. Add the line plt.axis('off')
after plt.imshow(image)
and it should remove this new axis.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.