rossant / smopy

OpenStreetMap image tiles in Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

enhancement : show_mpl method to take more arguments

mattgathu opened this issue · comments

def show_mpl(self, ax=None, figsize=None, dpi=None):
        """Show the image in matplotlib."""
        if not ax:
            plt.figure(figsize=figsize, dpi=dpi)
            ax = plt.subplot(111)
            plt.xticks([]);
            plt.yticks([]);
            plt.grid(False)
            plt.xlim(0, self.w);
            plt.ylim(self.h, 0)
            plt.axis('off');
            plt.tight_layout();
        ax.imshow(self.img);
        return ax

The current state of the show_mpl method (shown above) of the Map class does not allow passing of arguments to the ax.imshow(self.img) function.

My Scenario


  • I download a map tile from OSM.
  • Convert map tile to numpy image using to_numpy method.
  • Convert image to grayscale.
  • Assign Map.img the grayscale image.
  • Onwards continue using grayscale image.

Issue


For the grayscale image to display colors correctly I must pass a cmap parameter to the ax.imshow(self.img) function in this manner: `ax.imshow(self.img, cmap= plt.get_cmap('gray')).
This is not currently possible in Smopy.

Using **kwargs would probably do it, PR welcome :)

there is nothing in the function definition that allows for **kwargs. Can I fork this project and implement the enhancement?

Yes feel free to do it!