0

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 through Windows Photo

Image loaded in Pythin with TensorFlow library:

Image loaded in Pythin with TensorFlow library

Mehdi Zare
  • 1,221
  • 1
  • 16
  • 32

1 Answers1

1

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.