Facecolors not coloring the inside of the polygon spun by lineobject linesFill countries in python basemapHow can I do a line break (line continuation) in Python?How to print colored text in terminal in Python?How to get line count cheaply in Python?How to read a file line-by-line into a list?Matplotlib figure facecolor (background color)Correct way to write line to file?Catch multiple exceptions in one line (except block)Why is reading lines from stdin much slower in C++ than Python?Pythonic way to create a long multi-line stringCustomize Python legend

Renting a house to a graduate student in my department

If a character drops a magic item that turns on/off, does that item turn off when they drop it?

How to select certain lines (n, n+4, n+8, n+12...) from the file?

Detect the first rising edge of 3 input signals

Why do Thanos' punches not kill Captain America or at least cause some mortal injuries?

Would encrypting a database protect against a compromised admin account?

What does this quote in Small Gods refer to?

How to slow yourself down (for playing nice with others)

How to get my matrix to fit on the page

What's the difference between const array and static const array in C/C++

Why did they go to Dragonstone?

Are there variations of the regular runtimes of the Big-O-Notation?

How is CoreiX like Corei5, i7 is related to Haswell, Ivy Bridge?

Why use steam instead of just hot air?

Can the president of the United States be guilty of insider trading?

How to make a language evolve quickly?

Watching the game, having a puzzle

Which other programming languages apart from Python and predecessor are out there using indentation to define code blocks?

What can cause an unfrozen indoor copper drain pipe to crack?

How can I avoid subordinates and coworkers leaving work until the last minute, then having no time for revisions?

What was the notion of limit that Newton used?

No such column 'DeveloperName' on entity 'RecordType' after Summer '19 release on sandbox

The meaning of a て-form verb at the end of this sentence

Pre-1993 comic in which Wolverine's claws were turned to rubber?



Facecolors not coloring the inside of the polygon spun by lineobject lines


Fill countries in python basemapHow can I do a line break (line continuation) in Python?How to print colored text in terminal in Python?How to get line count cheaply in Python?How to read a file line-by-line into a list?Matplotlib figure facecolor (background color)Correct way to write line to file?Catch multiple exceptions in one line (except block)Why is reading lines from stdin much slower in C++ than Python?Pythonic way to create a long multi-line stringCustomize Python legend






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I'm trying to make a map of the Netherlands where the provinces are filled with some color. I've been looking to this SO post and this blog post for help and code examples. Except where they use



lines = LineCollection(shpsegs,antialiaseds=(1,))
lines.set_facecolors(cm.jet(np.random.rand(1)))


to fill up the shapes with a given color, this just doesn't do anything for me. I can't figure out why it's not doing anything for me. It's not giving me an error, and I also don't see any color in the shape.



I would really appreciate some help. My (almost) entire code is below, I trimmed off some unnecessary bits:



import shapefile
import matplotlib.pyplot as plt
import matplotlib as mpl
from matplotlib.collections import LineCollection
import numpy as np


##Importing shapefile and records
sf = shapefile.Reader("NLadmin/NLD_adm1")

records = sf.records()
for i in range(len(records)):
print(str(i) + " - " + str(records[i][4]))

shapes = sf.shapes()
for i in range(len(shapes)):
print(shapes[i].parts)


##Figure
fig = plt.figure()
ax = plt.axes()
ax.set_aspect(1.1541)
ax.set_xlim(3, 7.5)
ax.set_ylim(50.5, 54)

print("-------")

##Use the shapes and records
for shape, record in zip(list(sf.iterShapes()), records):
number_points = len(shape.points)
number_parts = len(shape.parts)

for index in range(number_parts):
startindex = shape.parts[index]

if index < len(shape.parts)-1:
endindex = shape.parts[index+1]
else:
endindex = number_points

shapesegment = shape.points[startindex:endindex]

x_lon = []
y_lat = []
for index in range(len(shapesegment)):
x_lon.append(shapesegment[index][0])
y_lat.append(shapesegment[index][1])


linelist = []
for i in range(len(x_lon)):
intermediatelist = []

try:
startxy = (x_lon[i], y_lat[i])
endxy = (x_lon[i+1], y_lat[i+1])
except:
continue

intermediatelist.append(startxy)
intermediatelist.append(endxy)
linelist.append(intermediatelist)


lines = LineCollection(linelist,antialiaseds=(1,))
lines.set_facecolors('#e41a1c')
lines.set_edgecolors('k')
lines.set_linewidth(1)

ax.add_collection(lines)


plt.show()










share|improve this question






















  • A line does not have any facecolor.

    – ImportanceOfBeingErnest
    Mar 23 at 11:18

















0















I'm trying to make a map of the Netherlands where the provinces are filled with some color. I've been looking to this SO post and this blog post for help and code examples. Except where they use



lines = LineCollection(shpsegs,antialiaseds=(1,))
lines.set_facecolors(cm.jet(np.random.rand(1)))


to fill up the shapes with a given color, this just doesn't do anything for me. I can't figure out why it's not doing anything for me. It's not giving me an error, and I also don't see any color in the shape.



I would really appreciate some help. My (almost) entire code is below, I trimmed off some unnecessary bits:



import shapefile
import matplotlib.pyplot as plt
import matplotlib as mpl
from matplotlib.collections import LineCollection
import numpy as np


##Importing shapefile and records
sf = shapefile.Reader("NLadmin/NLD_adm1")

records = sf.records()
for i in range(len(records)):
print(str(i) + " - " + str(records[i][4]))

shapes = sf.shapes()
for i in range(len(shapes)):
print(shapes[i].parts)


##Figure
fig = plt.figure()
ax = plt.axes()
ax.set_aspect(1.1541)
ax.set_xlim(3, 7.5)
ax.set_ylim(50.5, 54)

print("-------")

##Use the shapes and records
for shape, record in zip(list(sf.iterShapes()), records):
number_points = len(shape.points)
number_parts = len(shape.parts)

for index in range(number_parts):
startindex = shape.parts[index]

if index < len(shape.parts)-1:
endindex = shape.parts[index+1]
else:
endindex = number_points

shapesegment = shape.points[startindex:endindex]

x_lon = []
y_lat = []
for index in range(len(shapesegment)):
x_lon.append(shapesegment[index][0])
y_lat.append(shapesegment[index][1])


linelist = []
for i in range(len(x_lon)):
intermediatelist = []

try:
startxy = (x_lon[i], y_lat[i])
endxy = (x_lon[i+1], y_lat[i+1])
except:
continue

intermediatelist.append(startxy)
intermediatelist.append(endxy)
linelist.append(intermediatelist)


lines = LineCollection(linelist,antialiaseds=(1,))
lines.set_facecolors('#e41a1c')
lines.set_edgecolors('k')
lines.set_linewidth(1)

ax.add_collection(lines)


plt.show()










share|improve this question






















  • A line does not have any facecolor.

    – ImportanceOfBeingErnest
    Mar 23 at 11:18













0












0








0








I'm trying to make a map of the Netherlands where the provinces are filled with some color. I've been looking to this SO post and this blog post for help and code examples. Except where they use



lines = LineCollection(shpsegs,antialiaseds=(1,))
lines.set_facecolors(cm.jet(np.random.rand(1)))


to fill up the shapes with a given color, this just doesn't do anything for me. I can't figure out why it's not doing anything for me. It's not giving me an error, and I also don't see any color in the shape.



I would really appreciate some help. My (almost) entire code is below, I trimmed off some unnecessary bits:



import shapefile
import matplotlib.pyplot as plt
import matplotlib as mpl
from matplotlib.collections import LineCollection
import numpy as np


##Importing shapefile and records
sf = shapefile.Reader("NLadmin/NLD_adm1")

records = sf.records()
for i in range(len(records)):
print(str(i) + " - " + str(records[i][4]))

shapes = sf.shapes()
for i in range(len(shapes)):
print(shapes[i].parts)


##Figure
fig = plt.figure()
ax = plt.axes()
ax.set_aspect(1.1541)
ax.set_xlim(3, 7.5)
ax.set_ylim(50.5, 54)

print("-------")

##Use the shapes and records
for shape, record in zip(list(sf.iterShapes()), records):
number_points = len(shape.points)
number_parts = len(shape.parts)

for index in range(number_parts):
startindex = shape.parts[index]

if index < len(shape.parts)-1:
endindex = shape.parts[index+1]
else:
endindex = number_points

shapesegment = shape.points[startindex:endindex]

x_lon = []
y_lat = []
for index in range(len(shapesegment)):
x_lon.append(shapesegment[index][0])
y_lat.append(shapesegment[index][1])


linelist = []
for i in range(len(x_lon)):
intermediatelist = []

try:
startxy = (x_lon[i], y_lat[i])
endxy = (x_lon[i+1], y_lat[i+1])
except:
continue

intermediatelist.append(startxy)
intermediatelist.append(endxy)
linelist.append(intermediatelist)


lines = LineCollection(linelist,antialiaseds=(1,))
lines.set_facecolors('#e41a1c')
lines.set_edgecolors('k')
lines.set_linewidth(1)

ax.add_collection(lines)


plt.show()










share|improve this question














I'm trying to make a map of the Netherlands where the provinces are filled with some color. I've been looking to this SO post and this blog post for help and code examples. Except where they use



lines = LineCollection(shpsegs,antialiaseds=(1,))
lines.set_facecolors(cm.jet(np.random.rand(1)))


to fill up the shapes with a given color, this just doesn't do anything for me. I can't figure out why it's not doing anything for me. It's not giving me an error, and I also don't see any color in the shape.



I would really appreciate some help. My (almost) entire code is below, I trimmed off some unnecessary bits:



import shapefile
import matplotlib.pyplot as plt
import matplotlib as mpl
from matplotlib.collections import LineCollection
import numpy as np


##Importing shapefile and records
sf = shapefile.Reader("NLadmin/NLD_adm1")

records = sf.records()
for i in range(len(records)):
print(str(i) + " - " + str(records[i][4]))

shapes = sf.shapes()
for i in range(len(shapes)):
print(shapes[i].parts)


##Figure
fig = plt.figure()
ax = plt.axes()
ax.set_aspect(1.1541)
ax.set_xlim(3, 7.5)
ax.set_ylim(50.5, 54)

print("-------")

##Use the shapes and records
for shape, record in zip(list(sf.iterShapes()), records):
number_points = len(shape.points)
number_parts = len(shape.parts)

for index in range(number_parts):
startindex = shape.parts[index]

if index < len(shape.parts)-1:
endindex = shape.parts[index+1]
else:
endindex = number_points

shapesegment = shape.points[startindex:endindex]

x_lon = []
y_lat = []
for index in range(len(shapesegment)):
x_lon.append(shapesegment[index][0])
y_lat.append(shapesegment[index][1])


linelist = []
for i in range(len(x_lon)):
intermediatelist = []

try:
startxy = (x_lon[i], y_lat[i])
endxy = (x_lon[i+1], y_lat[i+1])
except:
continue

intermediatelist.append(startxy)
intermediatelist.append(endxy)
linelist.append(intermediatelist)


lines = LineCollection(linelist,antialiaseds=(1,))
lines.set_facecolors('#e41a1c')
lines.set_edgecolors('k')
lines.set_linewidth(1)

ax.add_collection(lines)


plt.show()







python matplotlib gis






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 23 at 10:01









JuamJuam

1




1












  • A line does not have any facecolor.

    – ImportanceOfBeingErnest
    Mar 23 at 11:18

















  • A line does not have any facecolor.

    – ImportanceOfBeingErnest
    Mar 23 at 11:18
















A line does not have any facecolor.

– ImportanceOfBeingErnest
Mar 23 at 11:18





A line does not have any facecolor.

– ImportanceOfBeingErnest
Mar 23 at 11:18












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55312577%2ffacecolors-not-coloring-the-inside-of-the-polygon-spun-by-lineobject-lines%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55312577%2ffacecolors-not-coloring-the-inside-of-the-polygon-spun-by-lineobject-lines%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript