User:Jarekt/Witkacy queries
KDM+dates
editSELECT ?item (YEAR(?date) as ?year) (MONTH(?date) as ?month) (DAY(?date) as ?day) ?dateprecision ?KDM WHERE {
?item wdt:P170 wd:Q381238 .
MINUS{ ?item wdt:P31 wd:Q3658341 .}
optional{
?item p:P571/psv:P571 ?timenode .
?timenode wikibase:timeValue ?date.
?timenode wikibase:timePrecision ?dateprecision.
}
optional{ ?item p:P528 [ pq:P972 wd:Q106425660; ps:P528 ?KDM] . }
}
order
editSELECT ?item ?Len ?kdm ?kdmn WHERE {
?item wdt:P170 wd:Q381238 . # Witkacy as creator
MINUS{ ?item wdt:P31 wd:Q3658341 .} # no literary characters
MINUS{ ?item wdt:P31 wd:Q125191 .} # no photographs
optional{ ?item p:P528 [ pq:P972 wd:Q106425660; ps:P528 ?kdm] . }
optional{ ?item wdt:P156/wdt:P528 ?prev .}
optional{ ?item wdt:P155/wdt:P528 ?next .}
bind( if( bound(?kdm) && strStarts(str(?kdm), "I "), CONCAT(STR( ?kdm ), ".5"),
if( bound(?next), CONCAT(STR( ?next ), ".9"),
if( bound(?prev), CONCAT(STR( ?prev ), ".1"),
"Z") ) ) as ?kdmn ) .
OPTIONAL {
?item rdfs:label ?Len
FILTER((LANG(?Len)) = "en")
}
filter (?item!=wd:Q107095853)
} order by ?kdmn
qid-KDM-img
editSELECT ?item ?KDM ?img WHERE {
?item wdt:P170 wd:Q381238 .
?item p:P528 [ pq:P972 wd:Q106425660; ps:P528 ?KDM] .
optional{ ?item wdt:P18 ?img. }
} order by ?KDM
Prace Witkacego opublikowane w Przekroju
edit#defaultView:ImageGrid
SELECT ?item ?number ?data ?Lpl ?img WHERE {
?item wdt:P170 wd:Q381238 .
?item p:P1433 [ ps:P1433 wd:Q2114540; pq:P433 ?number ; pq:P577 ?data] .
OPTIONAL {
?item rdfs:label ?Lpl
FILTER((LANG(?Lpl)) = "pl")
}
optional{ ?item wdt:P18 ?img. }
} order by ?number
images
editsmall images
edit# Federation with correlation - Get height and width for Commons images
# Run this from WCQS - https://commons-query.wikimedia.org/
SELECT ?item ?page ?image ?file ?width ?height
WHERE {
hint:Query hint:optimizer "None" .
SERVICE <https://query.wikidata.org/sparql> {
?item p:P1433 [ ps:P1433 wd:Q113870515; pq:P304 ?page_ ] ;
wdt:P18 ?image .
BIND(xsd:integer(?page_) as ?page) .
}
?file schema:url ?image ;
schema:height ?height ;
schema:width ?width .
}
ORDER BY (?width * ?height)
no images
editSELECT ?item ?itemLabel ?date ?collectionLabel WHERE {
?item wdt:P170 wd:Q381238 .
?item wdt:P571 ?date .
optional{ ?item wdt:P195 ?collection . }
MINUS{ ?item wdt:P31 wd:Q3658341 .} # no literary characters
MINUS{ ?item wdt:P18 ?img . }
SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
}
items without images
editSELECT ?item ?itemLabel ?date ?collectionLabel WHERE {
?item wdt:P170 wd:Q381238 .
?item wdt:P571 ?date .
optional{ ?item wdt:P195 ?collection . }
MINUS{ ?item wdt:P31 wd:Q3658341 .} # no literary characters
MINUS{ ?item wdt:P18 ?img . }
SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
}
museum pieces without image
editSELECT ?item ?itemLabel ?collectionLabel ?id ?kdm WHERE {
?item wdt:P170 wd:Q381238 .
?item wdt:P195 ?collection .
minus {?collection wdt:P31 wd:Q768717 }
optional{?item wdt:P217 ?id . }
optional{ ?item p:P528 [ pq:P972 wd:Q106425660; ps:P528 ?kdm] . }
MINUS{ ?item wdt:P18 [] . }
FILTER (!wikibase:isSomeValue(?collection))
SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
} order by ?collection
Muzea
editSELECT ?collection ?collectionLabel (count(?item) as ?count) (SAMPLE(?item) as ?sampleitem) WHERE {
?item wdt:P170 wd:Q381238 .
?item wdt:P195 ?collection .
minus {?collection wdt:P31 wd:Q768717 }
FILTER (!wikibase:isSomeValue(?collection))
SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
} group by ?collection ?collectionLabel
order by desc(?count)
missing fields
editmissing collection
editSELECT ?item ?img ?KDM ?collection WHERE {
?item wdt:P170 wd:Q381238 .
?item wdt:P18 ?img .
minus{ ?item wdt:P195 ?collection . }
minus{ ?item p:P528 [ pq:P972 wd:Q106425660; ps:P528 ?KDM] . }
} order by ?KDM
missing P31=pastel
editSELECT ?item ?itemLabel ?img WHERE {
?item wdt:P170 wd:Q381238 .
?item wdt:P186 wd:Q189085 .
?item wdt:P18 ?img .
MINUS{ ?item wdt:P31 wd:Q12043905 .}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
missing en descriptions
editSELECT ?item (YEAR(?date) as ?year) ?KDM ?itemDescription WHERE {
?item wdt:P170 wd:Q381238 .
?item wdt:P186 wd:Q189085 .
?item wdt:P571 ?date .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
optional{ ?item p:P528 [ pq:P972 wd:Q106425660; ps:P528 ?KDM] . }
}
copyright status
editSELECT ?item WHERE {
?item wdt:P170 wd:Q381238 .
MINUS{ ?item wdt:P31 wd:Q3658341 .}
#minus{ ?item wdt:P6216 wd:Q19652 }.
?item p:P6216 ?statement .
FILTER NOT EXISTS { ?statement pq:P1001 [] } # exclude if P1001 present
#FILTER NOT EXISTS { ?statement pq:P459 [] } # exclude if P459 present
}
missing references / brakujące źródła
editSELECT ?item ?KDM
WHERE {
?item wdt:P170 wd:Q381238 .
?item p:P528 [ pq:P972 wd:Q106425660; ps:P528 ?KDM; ] .
minus { ?item p:P528 [ prov:wasDerivedFrom [ pr:P248 [] ] ] } .
}
missing inscriptions/ brakujące sygnatury
editSELECT ?item ?img ?KDM WHERE {
?item wdt:P170 wd:Q381238 . optional{ ?item wdt:P18 ?img . } optional{ ?item p:P528 [ pq:P972 wd:Q106425660; ps:P528 ?KDM; ] . } minus { ?item wdt:P1684 [] } .
}
other
editsignature with "|"
editSELECT ?item ?ins WHERE {
?item wdt:P170 wd:Q381238.
?item wdt:P1684 ?ins .
FILTER (contains(str(?ins), "|" ))
}
genre
editSELECT ?item ?genre ?itemLabel WHERE {
?item wdt:P170 wd:Q381238 .
optional{ ?item wdt:P136 ?genre . }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
collection->location
editSELECT ?item ?collection ?loc WHERE {
?item wdt:P170 wd:Q381238 .
?item wdt:P195 ?collection .
minus{ ?item wdt:P276 ?loc . }
}
main subject
editSELECT ?item ?itemLabel WHERE {
?item wdt:P170 wd:Q381238 .
?item wdt:P136 wd:Q134307 .
minus {?item wdt:P921 ?depicts . }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
copy main subject based on label
editSELECT ?label ?subject1Label ?item2 ?subject1 WHERE {
?item1 wdt:P170 wd:Q381238 .
?item2 wdt:P170 wd:Q381238 .
?item1 wdt:P921 ?subject1 .
minus{ ?item2 wdt:P921 ?subject2 . }
?item1 rdfs:label ?label .
FILTER(LANG(?label) = 'pl') .
FILTER(?subject1 != wd:Q381238) .
?item2 rdfs:label ?label .
FILTER(LANG(?label) = 'pl') .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
Different works with the same KDM ID
editSELECT ?item1 ?item2 ?id WHERE {
?item1 wdt:P170 wd:Q381238 .
?item2 wdt:P170 wd:Q381238 .
?item1 wdt:P528 ?id.
?item2 wdt:P528 ?id.
FILTER(?item1 != ?item2) .
FILTER(strlen(?id)<=6) .
}
publications with Witkacy artworks
editSELECT ?pub ?pubLabel (count(?item) as ?count) WHERE {
?item wdt:P170 wd:Q381238 .
?item wdt:P1433 ?pub.
SERVICE wikibase:label { bd:serviceParam wikibase:language "pl" }
} group by ?pub ?pubLabel
order by ?count
osoby portretowane
editSELECT ?person ?personLabel (count(?item) as ?count) WHERE {
?item wdt:P170 wd:Q381238 .
?item wdt:P921 ?person.
SERVICE wikibase:label { bd:serviceParam wikibase:language "pl" }
} group by ?person ?personLabel
order by desc(?count)
survey significant events
editSELECT ?event ?eventLabel (count(?item) as ?count) (SAMPLE(?item) as ?sampleitem) WHERE {
?item wdt:P170 wd:Q381238 .
?item wdt:P793 ?event .
SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
} group by ?event ?eventLabel
bad significant events
editSELECT ?item WHERE {
?item wdt:P170 wd:Q381238 .
?item p:P793 ?statement .
?statement pq:P585 ?date1.
?statement pq:P585 ?date2.
Filter (?date1 > ?date2).
}
SELECT ?item WHERE {
?item wdt:P170 wd:Q381238 .
?item wdt:P793 wd:Q9209474 .
}
survey medium
editSELECT ?med ?medLabel (count(?item) as ?count) (SAMPLE(?item) as ?sampleitem) WHERE {
?item wdt:P170 wd:Q381238 .
?item wdt:P186 ?med .
SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
} group by ?med ?medLabel
survey art shows
editSELECT ?item ?itemLabel WHERE {
?item wdt:P921 wd:Q381238 .
?item wdt:P31 wd:Q667276 .
SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
}
self-portraits / autoportrety
editSELECT ?item ?KDM ?Lpl ?img WHERE {
?item wdt:P170 wd:Q381238 .
?item wdt:P136 wd:Q192110 .
OPTIONAL {
?item rdfs:label ?Lpl
FILTER((LANG(?Lpl)) = "pl")
}
optional{ ?item p:P528 [ pq:P972 wd:Q106425660; ps:P528 ?KDM] . }
optional{ ?item wdt:P18 ?img. }
minus{ ?item wdt:P31 wd:Q125191 }
} order by ?KDM
auctions
editauction houses
editSELECT ?loc ?locLabel (count(?item) as ?count) (SAMPLE(?item) as ?sampleitem) WHERE {
?item wdt:P170 wd:Q381238 .
?item p:P793 ?statement .
?statement pq:P276 ?loc.
?statement ps:P793 wd:Q177923
SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
} group by ?loc ?locLabel
order by desc(?count)
auction house images by url
editSELECT ?item ?img WHERE {
?item wdt:P170 wd:Q381238 .
?item wdt:P973 ?url .
?item wdt:P18 ?img .
FILTER (STRSTARTS(STR(?url), "https://www.sda.pl"))
}
auction house images by q-id
editSELECT ?item ?img WHERE {
?item wdt:P170 wd:Q381238 .
?item wdt:P18 ?img .
?item p:P793 ?statement .
?statement pq:P276 wd:Q503176.
}
catalog auction results
editSELECT ?item ?img ?locLabel ?date ?price WHERE {
?item wdt:P170 wd:Q381238 .
?item wdt:P18 ?img .
?item p:P793 ?statement .
?statement pq:P276 ?loc.
?statement pq:P585 ?date.
optional{?statement pq:P2284 ?price.}
optional{?statement pq:P4775 ?lot.}
?statement ps:P793 wd:Q177923
SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
} order by desc(?date)
catalog auction results in last 3 months
editSELECT ?item ?img ?locLabel ?date ?price WHERE {
?item wdt:P170 wd:Q381238 .
?item wdt:P18 ?img .
?item p:P793 ?statement .
?statement pq:P276 ?loc.
?statement pq:P585 ?date.
optional{?statement pq:P2284 ?price.}
optional{?statement pq:P4775 ?lot.}
?statement ps:P793 wd:Q177923
SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
FILTER(BOUND(?date) && DATATYPE(?date) = xsd:dateTime).
# not in the future, and not more than 90 days ago
BIND(NOW() - ?date AS ?distance).
FILTER(0 <= ?distance && ?distance < 90).
} order by desc(?date)
most frequently auctioned artworks
editSELECT ?item (count(?item) as ?count) (SAMPLE(?img) as ?sampleimg) WHERE {
?item wdt:P170 wd:Q381238 .
?item wdt:P18 ?img .
?item p:P793 ?statement .
?statement ps:P793 wd:Q177923
} group by ?item
order by desc(?count)
jak często są prace na aukcjach
editSELECT ?count_auctions_per_artwork (count(?item) as ?count_artworks) WHERE {
{SELECT ?item (count(?item) as ?count_auctions_per_artwork) WHERE {
?item wdt:P170 wd:Q381238 .
?item p:P793/ps:P793 wd:Q177923
} group by ?item }
} group by ?count_auctions_per_artwork
order by ?count_auctions_per_artwork
mean price per year
editSELECT ?year (round(AVG(?price)) as ?mean) WHERE {
?item wdt:P170 wd:Q381238 .
?item p:P793 ?statement .
?statement pq:P585 ?date.
?statement pq:P2284 ?price.
FILTER ( ! wikibase:isSomeValue(?price))
BIND ( YEAR(?date) as ?year).
} group by ?year
order by ?year
aukcje/ceny/waluty
editSELECT ?item ?locLabel ?date ?price ?unitLabel WHERE {
?item wdt:P170 wd:Q381238 .
?item wdt:P18 ?img .
?item p:P793 ?statement .
?statement pq:P276 ?loc.
?statement pq:P585 ?date.
?statement pq:P2284 ?price_statement.
?statement pqv:P2284 [ wikibase:quantityAmount ?price ; wikibase:quantityUnit ?unit ] .
?statement ps:P793 wd:Q177923
SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
} order by desc(?date)
python |
---|
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 27 23:44:51 2024
@author: tuszynskij
"""
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import datetime as dt
import pandas as pd
import numpy as np
import random
from PIL import ImageColor
# https://www.zus.pl/en/baza-wiedzy/skladki-wskazniki-odsetki/wskazniki/minimalne-i-przecietne-wynagrodzenie
# https://www.zus.pl/en/baza-wiedzy/skladki-wskazniki-odsetki/wskazniki/przecietne-wynagrodzenie-w-latach
salary= np.array([
[1991, 2124],
[1992, 3522],
[1993, 4794],
[1994, 6393.6],
[1995, 8431.44],
[1996, 10476],
[1997, 12743.16],
[1998, 14873.88],
[1999, 20480.88],
[2000, 23085.72],
[2001, 24742.20],
[2002, 25598.52],
[2003, 26417.64],
[2004, 27474.84],
[2005, 28563.48],
[2006, 29726.76],
[2007, 32292.36],
[2008, 35326.56],
[2009, 37235.52],
[2010, 38699.76],
[2011, 40794.24],
[2012, 42260.04],
[2013, 43800.72],
[2014, 45401.52],
[2015, 46797.36],
[2016, 48566.52],
[2017, 51258.12],
[2018, 55020.36],
[2019, 59018.04],
[2020, 62009.64],
[2021, 67950.36],
[2022, 76153.80],
[2023, 86595.99],
[2024, 97768.56]
])
colors = np.array(['#789EC9', '#549E79', '#AA5199', '#B77B68', '#6367A9',
'#59738A', '#6B94AA', '#FF2F80', '#A3A489', '#636375', '#809693',
'#837393', '#D83D66', '#83AB58', '#A88C85', '#7D5A44', '#D20096',
'#997D87', '#64547B', '#6C8F7D', '#958A9F', '#BF5650', '#6A714A',
'#55813B', '#895563', '#788D66', '#9695C5', '#0AA3F7', '#EA8B66',
'#962B75', '#B88183', '#BC23FF', '#B903AA', '#83A485', '#BEC459',
'#518A87', '#A38469', '#CCAA35', '#76912F', '#CC0744', '#CA834E',
'#D86A78', '#5EFF03', '#9B9700', '#8D8546', '#0086ED', '#00A6AA',
'#D16100', '#FF4A46', '#D68E01', '#61615A', '#78AFA1', '#A079BF',
'#4FC601', '#7ED379', '#98D058', '#E83000', '#938A81', '#3B5DFF',
'#00D891', '#797868', '#006FA6', '#868E7E', '#51A058', '#8BB400',
'#658188', '#943A4D', '#7A87A1', '#1BE177', '#A4E804', '#4B8160',
'#9C6966', '#A76F42', '#886F4C', '#3E89BE', '#E704C4', '#B05B6F',
'#00FECF', '#9FA064', '#885578', '#97979E', '#CB7E98', '#6D80BA',
'#E98176', '#A05837', '#00C6C8', '#FF1A59', '#71BB8C', '#15A08A',
'#A74571', '#0060CD', '#C86240', '#A97399', '#B79762', '#D157A0',
'#FF913F', '#0AA6D8', '#C6005A', '#0045D2', '#0089A3', '#FFB500',
'#00C2A0', '#04F757', '#75797C', '#FF6832', '#7C6571', '#806C66',
'#DA007C', '#5EBCD1', '#0CBD66', '#7900D7', '#7B4F4B', '#9556BD',
'#456D75', '#A77500', '#72418F', '#66796D'])
linestyles = ['dotted', 'dashdot', 'dashed', 'solid']
df = pd.read_csv(r"C:\projects\witkacy\auction_prices_2.csv")
df['dtime'] = [dt.datetime.strptime(d,"'%Y-%m-%d").date() for d in df.date]
df['x'] = 0
print(df.head())
lab1 = []
lab2 = []
fig = plt.figure(figsize=(11.0,7.0)) # in inches!
ax = fig.add_subplot(1, 1, 1)
year = [dt.datetime.strptime(str(int(d)),"%Y").date() for d in salary[:,0]]
line1, = ax.plot(year, salary[:,1], 'r', linewidth=4, label='przeciętna\nroczna\npłaca')
lab1.append(line1)
qids = df['item'].unique()
n = 0
for i, qid in enumerate(qids):
msk = (df['item'] == qid)
k = min(sum(msk), 5)
if (k>1):
color = colors[n]
line1, = ax.plot(df.dtime[msk], df.price[msk], color=color, linestyle=linestyles[k-2], label=qid)
if (sum(msk)>2):
lab1.append(line1)
for m in df.marker[msk].unique():
msk2 = (df['item'] == qid) & (df['marker'] == m)
ax.scatter(df.dtime[msk2], df.price[msk2], marker = m, color=color)
n=n+1
else:
df.loc[msk, 'x'] = 1
df2 = df[df['x'] == 1]
for m in np.array(['o', 'D', '<', 'v', '^', 's']):
msk = (df['marker'] == m)
lab = df2.dom[msk].iloc[0] if m!='s' else 'inne'
line2 = ax.scatter(df2.dtime[msk], df2.price[msk], marker = m, color='k', label=lab)
lab2.append(line2)
print(n)
plt.xlabel('Rok', fontsize=12)
plt.ylabel('Ceny (PLN)', fontsize=12)
ax.set_yscale('log')
#plt.title('Ceny prac Witkacego', fontsize=20)
plt.grid()
first_legend = ax.legend(handles=lab2, loc='upper left', title='Domy aukcyjne:')
ax.add_artist(first_legend)
plt.legend(handles=lab1, bbox_to_anchor=(1.01, 1), loc="upper left")
plt.tight_layout()
plt.show()
fig.savefig('Ceny prac Witkacego.png', bbox_extra_artists=[first_legend,]) #, bbox_inches='tight')
|
Statistics
editnumber of works per year
editSELECT ?year (count(?item) as ?count) (SAMPLE(?item) as ?sampleitem) WHERE {
?item wdt:P170 wd:Q381238 .
?item wdt:P571 ?date.
BIND ( YEAR(?date) as ?year).
} group by ?year
order by ?year
number of works per month
editSELECT ?month (count(?item) as ?count) WHERE {
?item wdt:P170 wd:Q381238 .
?item p:P571/psv:P571 ?timenode .
?timenode wikibase:timeValue ?date.
?timenode wikibase:timePrecision ?dateprecision.
FILTER(?dateprecision > 9).
Bind(MONTH(?date) as ?month)
} group by ?month
order by ?month
number of works per day of the week
editSELECT ?mod (count(?item) as ?count) WHERE {
?item wdt:P170 wd:Q381238 .
?item p:P571/psv:P571 ?timenode .
?timenode wikibase:timeValue ?date.
?timenode wikibase:timePrecision ?dateprecision.
FILTER(?dateprecision = 11).
BIND (?date - "1900-01-01"^^xsd:date AS ?ndays)
# Compute modulo by 7 without a modulo operator
BIND (floor(?ndays - (7 * floor(?ndays/7))) AS ?mod)
} group by ?mod
order by ?mod
technique
editSELECT ?materialLabel (count(?item) as ?count) WHERE {
?item wdt:P170 wd:Q381238 .
?item wdt:P186 ?material.
SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
} group by ?materialLabel
order by desc(?count)
number of works per year + technique
editSELECT ?year ?materialLabel (count(?item) as ?count) WHERE {
?item wdt:P170 wd:Q381238 .
?item wdt:P571 ?date.
?item wdt:P186 ?material.
VALUES ?material {
wd:Q189085
wd:Q14674
wd:Q1424515
wd:Q296955
} .
BIND ( YEAR(?date) as ?year).
SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
} group by ?year ?materialLabel
order by ?year ?materialLabel
Statistics related to ownership
editnumber of items in museums
editSELECT (count(?item) as ?count) WHERE {
?item wdt:P170 wd:Q381238 .
?item wdt:P195 ?collection .
minus{ ?collection wdt:P31 wd:Q768717 }
FILTER (!wikibase:isSomeValue(?collection))
}
number of items in named private collections
editSELECT (count(?item) as ?count) WHERE {
?item wdt:P170 wd:Q381238 .
?item p:P195 ?statement .
?statement ps:P195 ?collection .
?collection wdt:P31 wd:Q768717 .
FILTER NOT EXISTS { ?statement pq:P518 wd:Q114187913} # exclude if P1001 for USA present
FILTER (!wikibase:isSomeValue(?collection))
}
number of items in private collections
editSELECT (count(?item) as ?count) WHERE {
?item wdt:P170 wd:Q381238 .
?item p:P195 ?statement.
?statement pq:P3831 wd:Q768717 .
Minus{ ?statement pq:P518 wd:Q114187913 }
}
lost works known from photographs
editSELECT (count(?item) as ?count) WHERE {
?item wdt:P170 wd:Q381238 .
?item p:P195/pq:P828 wd:Q4140840 .
?item p:P195/pq:P518 wd:Q114187913 .
}