Repository navigation
Library API: import graphier, plot the graph and chronology - #16
Merged
Merged
Conversation
matplotlib-style package use — same graph, same provenance, no web app:
import graphier
v = graphier.open('~/notes')
v.entities('PERSON'); v.relations('founded by')
v.query('?- empire_builder(P, B)')
v.to_networkx()
v.plot_graph(); v.plot_timeline()
- graphier.api.VaultSession: entities/relations/entity/search/query/
conflicts/inferred/timeline as plain dicts, every asserting row
carrying its sentence evidence; to_networkx() for interop with any
graph tool (pyvis, plotly, gephi…).
- plot_graph(): kamada-kawai layout, entity-type colors matching the
app palette, degree-based sizing, predicate edge labels, type legend.
UNKNOWN and DATE nodes excluded from the drawing by default (data
remains available); to_networkx() excludes only UNKNOWN.
- plot_timeline(): entity lifelines — rows per entity on a shared year
axis, dots per dated event, span lines, recessive grid.
- matplotlib is optional via the graphier[viz] extra; without it the
plot methods raise a friendly install hint (tested).
- README gains a 'Use it as a library' section with generated figures;
CI installs matplotlib so plot tests run; CHANGELOG updated.
- 4 new tests (59 total).
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QVbxD1gd3gsC6zXKE6L3ya
plot_graph: - Only typed relations are drawn by default; generic related_to co-occurrence edges are excluded from the drawing (include_related=True restores them) — they were the grey mesh drowning the signal. - Curved edges with proper arrowheads; italic predicate labels on a soft ground chip; node labels sit below nodes with a paper-color halo and greedy collision nudging, never on top of the mark. - Warm paper background matching the app, left-aligned bold title, frameless title-cased legend, comfortable margins. plot_timeline: - Year-span annotations at the end of each lifeline (1942–2024). - Round-capped span lines, paper-ring dots, recessive grid, no spines, left-aligned bold title, x padding so annotations never clip. Both README figures regenerated from the demo vault. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QVbxD1gd3gsC6zXKE6L3ya
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follows the merged #15. Graphier becomes a proper Python library, matplotlib-style — the knowledge graph and chronology in a script or Jupyter notebook, no web app required:
What's in it
graphier.api.VaultSession— data access as plain dicts, every asserting row carrying its sentence evidence (same provenance discipline as the app and MCP server).to_networkx()— the escape hatch: hand the typed graph (predicates, origins, evidence on edges) to pyvis, plotly, gephi, or your own analysis. UNKNOWN noise nodes excluded by default.plot_graph()— Kamada-Kawai layout, entity-type colors matching the app palette, degree-based node sizing, predicate edge labels, type legend. DATE nodes excluded from the drawing by default (they connect to everything; the timeline plot covers time) — documented and overridable.plot_timeline()— entity lifelines: rows per entity on a shared year axis, a dot per dated event, span lines, recessive grid.graphier[viz]extra); without it the plot methods raise a friendly one-line install hint (tested), keeping the base install lean.Both README figures are real output from the demo vault:
Testing
4 new tests (59 total): data access + Datalog + entity dossier through the public API, networkx export with edge evidence, both plots rendering with real artists and correct row labels under the Agg backend, and the friendly no-matplotlib error. CI now installs matplotlib so the plot tests run there too.
🤖 Generated with Claude Code
https://claude.ai/code/session_01QVbxD1gd3gsC6zXKE6L3ya
Generated by Claude Code