Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

attributions severely wrapped upon savefig #211

Open
@Matthew-J-Payne

Description

Hey contextily, thanks for all your work for this library - really great.

Apologies for the gigantic .pngs!

So when I visualise a plot using contextily.add_basemap(), when viewing the plot using jupyter inline, I get a nice unwrapped attribution (showing you via windows snipping tool, hence low dpi), which I would like to be reflected when the .png is saved:

image

But, when saving I get this:

for_pr

My script, below:

import geopandas as gpd
import contextily as ctx
rivers_shapefile = gpd.read_file('datasets/rivers.shp')
rivers_shapefile['class'] = 'rivers'
fig, ax = plot.subplots(figsize = (8, 8))
rivers_shapefile.plot(column = 'class',
 ax = ax,
 cmap = 'bwr',
 linewidth = 0.6,
 zorder = 4,
 alpha = 0)
ctx.add_basemap(ax = ax,
 source = ctx.providers.CartoDB.Voyager,
 zorder = 1,
 zoom = 8,
 attribution = "© OpenStreetMap contributors 2023. Distributed under the Open Data Commons Open Database License (ODbL) v1.0",
 attribution_size = 6,
 crs = 32649)
ax.xaxis.set_major_locator(plot.MaxNLocator(4))
ax.yaxis.set_major_locator(plot.MaxNLocator(4))
custom_xticklabels_4 = ["0", "114.1°E", "114.6°E", "115.1°E", "115.6°E"]
custom_yticklabels_4 = ["0", "2.7°N", "3.3°N" , "3.8°N", "4.3°N"]
ax.set_xticklabels(custom_xticklabels_4)
ax.set_yticklabels(custom_yticklabels_4)
fig.savefig(fname = "outputs/for_pr.png", dpi = 1200, facecolor = "white", bbox_inches = "tight")
plot.show() # plots for debugging, defaults to low res plot

The plot is for a paper in review, so I can't publicly share the data, but happy to send across.
Contextily version is 1.3.0 and geopandas 0.12.2.

Any pointers in the right direction is appreciated, thank you!

All the best,
Matt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /