2

I'm trying to display the histogram for the bands but I keep getting the following object whenever I execute show_hist.

enter image description here

Here is the code I executed:

from rasterio.plot import show_hist
show_hist(full_dataset, bins=50, lw=0.0, stacked=False, alpha=0.3,
              histtype='stepfilled', title="Histogram")

How do I remove from the plot? Moreover, the legend is not shown. Could this be related to the very large values?

1 Answer 1

1

You have to encapsulate your code in a matplotlib figure.

import matplotlib.pyplot as plt
import rasterio
from rasterio.plot import show_hist

src = rasterio.open("file.tif")
fig, axhist = plt.subplots(1, 1, figsize=(20, 20))
show_hist(src, ax=axhist, bins=100, lw=0.0, stacked=False, alpha=0.3, histtype='stepfilled', density=True, title="Title")
axhist.get_legend().remove()
plt.show()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.