query-523318c7c3baad4b3dda92bb420b6078
Map: Set individual colors for ordinal scaleThe following query is counting the numbers of co-authors from a specific author identified by his/her orcid grouped by the co-authors country of citizenship:
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:Map
SELECT ?coauthor_countryLabel ?shape ?numOfCoAuthors ?layer ?rgb
WHERE {
{
SELECT ?shape ?coauthor_country (COUNT(?author) AS ?numOfCoAuthors) WHERE {
{
SELECT ?author ?searched_author WHERE {
# Find co-authors
?searched_author wdt:P496 "0000-0002-6778-0887".
?work wdt:P50 ?searched_author, ?author .
}
GROUP BY ?author ?searched_author
}
# Exclude self-links
FILTER (?searched_author != ?author)
?author wdt:P27 ?coauthor_country .
?coauthor_country wdt:P3896 ?shape.
}GROUP BY ?shape ?coauthor_country
} # Label the results
BIND(IF(?numOfCoAuthors <= 2,"< 2 Authors",
IF(?numOfCoAuthors < 5,"< 5 Authors",
IF(?numOfCoAuthors < 10,"< 10 Authors","> 10 Authors"))) AS ?layer).
#Set ColorRange for Ordinal Scale
BIND(IF(?numOfCoAuthors <= 2,"#fef0d9",
IF(?numOfCoAuthors < 5,"#fdcc8a",
IF(?numOfCoAuthors < 10,"#fc8d59","#d7301f"))) AS ?rgb).
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY DESC(?numOfCoAuthors)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?author")
v5("?coauthor_country")
v7("?layer"):::projected
v7("?numOfCoAuthors"):::projected
v8("?rgb"):::projected
v2("?searched_author")
v6("?shape"):::projected
v4("?work")
c7(["bd:serviceParam"]):::iri
c2(["0000-0002-6778-0887"]):::literal
c9(["#91;AUTO_LANGUAGE#93;,en"]):::literal
f0[["?searched_author != ?author"]]
f0 --> v2
f0 --> v3
v2 --"wdt:P496"--> c2
v4 --"wdt:P50"--> v2
v4 --"wdt:P50"--> v3
v3 --"wdt:P27"--> v5
v5 --"wdt:P3896"--> v6
bind2[/"count(?author)"/]
v3 --o bind2
bind2 --as--o v7
bind3[/"if(?numOfCoAuthors <= '2^^xsd:integer','< 2 Authors',if(?numOfCoAuthors < '5^^xsd:integer','< 5 Authors',if(?numOfCoAuthors < '10^^xsd:integer','< 10 Authors','> 10 Authors')))"/]
v7 --o bind3
bind3 --as--o v7
bind4[/"if(?numOfCoAuthors <= '2^^xsd:integer','#fef0d9',if(?numOfCoAuthors < '5^^xsd:integer','#fdcc8a',if(?numOfCoAuthors < '10^^xsd:integer','#fc8d59','#d7301f')))"/]
v7 --o bind4
bind4 --as--o v8
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c7 --"wikibase:language"--> c9
end