Wikidata depiction SPARQL queries

import urllib.parse
from IPython.display import IFrame
baseurl='https://query.wikidata.org/embed.html#'

def wdq(query='',width=800,height=500):
  return IFrame(baseurl+urllib.parse.quote(query), width=width, height=height)

What are the most depicted things in paintings in Wikidata?

wdq("""
# Most depicted things in paintings
#defaultView:BubbleChart
SELECT ?depictstatementLabel ?count {
  {
  SELECT ?depictstatement (COUNT(?depictstatement) AS ?count) WHERE {
    SELECT ?item ?depictstatement WHERE {
      ?item wdt:P31/wdt:P279* wd:Q3305213 .
      ?item wdt:P180 ?depictstatement .
    } LIMIT 300000
  } GROUP BY ?depictstatement
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }         
} ORDER BY DESC(?count) LIMIT 100
""")

Which collections have the most depicts statements for paintings?

wdq("""
SELECT ?collectionLabel ?count {
  {
  SELECT ?collection (COUNT(?collection) AS ?count) WHERE {
    SELECT ?item ?collection WHERE {
      ?item wdt:P31/wdt:P279* wd:Q3305213 .
      ?item wdt:P180 ?depictstatement .
      ?item wdt:P195 ?collection .
    } LIMIT 300000
  } GROUP BY ?collection
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }         
} ORDER BY DESC(?count) LIMIT 100
""")

Artists whose works have the most depicts statements

wdq(width=1000,height=800,query="""
SELECT ?cLabel ?count {
  {
  SELECT ?c (COUNT(?c) AS ?count) WHERE {
    SELECT ?item ?c WHERE {
      ?item wdt:P31/wdt:P279* wd:Q3305213 .
      ?item wdt:P180 ?depictstatement .
      ?item wdt:P170 ?c .
    } LIMIT 300000
  } GROUP BY ?c
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }         
} ORDER BY DESC(?count) LIMIT 100
""")

Timeline of most prominent artists at CMA

wdq(width=1000,height=1000,query="""
#defaultView:Timeline
# Show histogram of creators for all artworks that match GLAM entity
SELECT DISTINCT ?q ?qLabel ?count ?dob ?img WHERE
{
    {
      SELECT ?q (COUNT(?q) as ?count) WHERE {
        # Replace with the GLAM institution
        BIND (wd:Q657415 AS ?institution)
        ?item p:P217 [ps:P217 ?id; pq:P195 ?institution] .
        ?item wdt:P170 ?q . # Creators
        FILTER NOT EXISTS { ?item wdt:P170 wd:Q4233718 } # Filter out anonymous
      } 
    GROUP BY ?q ?qLabel
    } 
    OPTIONAL { ?q wdt:P569 ?dob }
    OPTIONAL { ?q wdt:P18 ?img }
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} 
ORDER BY DESC (?count)
LIMIT 50
""")

Map of place of birth for most prominent artists in CMA

wdq("""
#defaultView:Map
# Show place of birth locations for most prominent artists
SELECT DISTINCT ?q ?qLabel ?pobLabel ?coord ?img WHERE
{
    {
      SELECT ?q (COUNT(?q) as ?count) WHERE {
        # Replace with the GLAM institution
        BIND (wd:Q657415 AS ?institution)
        ?item p:P217 [ps:P217 ?id; pq:P195 ?institution] .
        ?item wdt:P170 ?q . # Creators
        FILTER NOT EXISTS { ?item wdt:P170 wd:Q4233718 } # Filter out anonymous
      } 
    GROUP BY ?q ?qLabel
    } 
    OPTIONAL { ?q wdt:P19 ?pob . ?pob wdt:P625 ?coord }
    OPTIONAL { ?q wdt:P18 ?img }
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} 
ORDER BY DESC (?count)
LIMIT 50
""")