Итак, мой код выглядит так:
Код: Выделить всё
from matplotlib import pyplot as plt
import networkx as nx
import osmnx as ox
import requests
import matplotlib.cm as cm
import matplotlib.colors as colors
from matplotlib.lines import Line2D
#import pillow as PIL
# To add text and a border to the map
from PIL import Image, ImageOps, ImageColor, ImageFont, ImageDraw
north = latitude +0.04
south = latitude -0.10
east = longitude +0.10
west = longitude -0.08
def makemap (n, s, e, w):
fig, ax = ox.plot_graph(G, node_size=0#, bbox = (n, s, e, w)
, dpi = 1200, bgcolor = "#000038",
save = False, edge_color=roadColors,
edge_linewidth=roadWidths, edge_alpha=1)
fig.tight_layout(pad=0)
return fig
makemap(north, south, east, west)
#asking questions....
fig.savefig("%s.png"% (place), dpi=1200, bbox_inches='tight', format="png", facecolor=fig.get_facecolor())
Поэтому я попробовал return fig(). Тогда я получаю «fig не является вызываемым объектом».
Это работает только тогда, когда я помещаю строку сохранения в функцию следующим образом:
Код: Выделить всё
north = latitude +0.04
south = latitude -0.10
east = longitude +0.10
west = longitude -0.08
def makemap (n, s, e, w):
fig, ax = ox.plot_graph(G, node_size=0#, bbox = (n, s, e, w)
, dpi = 1200, bgcolor = "#000038",
save = False, edge_color=roadColors,
edge_linewidth=roadWidths, edge_alpha=1)
fig.tight_layout(pad=0)
fig.savefig("%s.png"% (place), dpi=1200, bbox_inches='tight', format="png", facecolor=fig.get_facecolor())
makemap(north, south, east, west)
#asking questions....
Может ли кто-нибудь из сообщества помочь мне, как вернуть fig?
Подробнее здесь: https://stackoverflow.com/questions/740 ... a-function