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

해남서초등학교 학교 연혁 학교 동문 외부 링크 둘러보기 메뉴북위 34° 34′ 21″ 동경 126° 35′ 50″ / 북위 34.5726385° 동경 126.5972670°  / 34.5726385; 126.5972670해남서초등학교eh

How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?