Skip to main content

Visualization library for SPARQL query results

Project description

VizKG

Open In Colab Python Versions PyPI Version PyPI License

Visualization library for SPARQL query results

Installation

Use the package manager pip to install VizKG.

pip install VizKG

Usage

# Import the library
import VizKG.visualize as vkg

Wikidata: COVID-19 Vaccine Origins

sparql_query = """
SELECT DISTINCT ?vaccineLabel ?originCountry  {
  ?vaccine wdt:P1924 wd:Q84263196 .
  ?vaccine wdt:P178 ?developer.
  ?vaccine rdfs:label ?vaccineLabel .
  ?developer wdt:P17 ?origin . 
  ?origin rdfs:label ?originCountry .
  FILTER (LANG(?vaccineLabel) = 'en').
  FILTER (LANG(?originCountry) = 'en').
}LIMIT 25
"""
#to query another endpoint, change the URL for the service and the query
sparql_service_url = "https://query.wikidata.org/sparql"
chart = vkg(sparql_query=sparql_query, sparql_service_url=sparql_service_url, chart='sunburst')
chart.plot()

WD:COVID-19 Vaccine origins

DBpedia: Map of Temples in Indonesia

sparql_query = """
SELECT * WHERE {
  ?item dbo:wikiPageWikiLink dbr:Candi_of_Indonesia;
        geo:geometry ?geo .
  ?item rdfs:label ?itemLabel.
  FILTER((LANG(?itemLabel)) = "en")
}
"""
#to query another endpoint, change the URL for the service and the query
sparql_service_url = "https://dbpedia.org/sparql/"
chart = vkg(sparql_query=sparql_query, sparql_service_url=sparql_service_url, chart='map')
chart.plot()

DBpedia:Map of Temples in Indonesia

OU_UK: Number of Employees by Job Title

sparql_query = """
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX schema: <http://schema.org/jobTitle>

SELECT DISTINCT ?jobTitle (COUNT(?jobTitle) as ?count) WHERE {?s a foaf:Person .
  ?s <http://schema.org/jobTitle> ?jobTitle .
  FILTER (lang(?jobTitle) != 'en')
}
GROUP BY ?jobTitle
HAVING (?count > 10)
"""
#to query another endpoint, change the URL for the service and the query
sparql_service_url = "https://data.open.ac.uk/sparql"
chart = vkg(sparql_query=sparql_query, sparql_service_url=sparql_service_url, chart='TreeMap')
chart.plot()

OU_UK:Number of Employees by Job Title

Budaya KB: Number of Temples by Indonesian Regencies

sparql_query = """
prefix bkb: <https://budayakb.cs.ui.ac.id/ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>


SELECT ?provLabel (COUNT(?temple) AS ?numTemple) WHERE {
  ?temple a bkb:Candi .
  ?temple bkb:locationInProvince ?prov .
  ?prov rdfs:label ?provLabel.
  FILTER (lang(?provLabel) = 'id')

} GROUP BY ?provLabel
ORDER BY DESC(?numTemple)
"""
#to query another endpoint, change the URL for the service and the query
sparql_service_url = "https://budayakb.cs.ui.ac.id/budaya/sparql"
chart = vkg(sparql_query=sparql_query, sparql_service_url=sparql_service_url, chart='bubble')
chart.plot()

BudayaKB:Number of Temples by Indonesian Regencies

Supported Visualizations

  • Table
  • ImageGrid
  • Map
  • Tree
  • Timeline
  • Dimensions
  • Graph
  • WordCloud
  • Tree Map
  • SunBurst Chart
  • Line Chart
  • Bar Chart
  • Area Chart
  • StackedArea Chart
  • Histogram
  • Density Plot
  • Box Plot
  • Violin Plot
  • Bubble Chart
  • Scatter Chart
  • HeatMap
  • Radar Chart

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

VizKG-1.0.3.tar.gz (18.5 kB view hashes)

Uploaded Source

Built Distribution

VizKG-1.0.3-py3-none-any.whl (31.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page