Open eyalk11 opened 4 months ago
Could you be more specific about what is not working? :)
Same error but with figure.metadata and I am using figure.metadata instead of metadadata because this function is not there and if i use the first one it throws the same error as the OP
Error -
SVGAnnotationError Traceback (most recent call last)
Cell In[12], line 1
----> 1 figure.metadata
File D:\Anaconda\envs\eme\lib\site-packages\svgdigitizer\svgfigure.py:1629, in SVGFigure.metadata(self)
1507 @property
1508 def metadata(self):
1509 r"""
1510 A dict with properties of the original figure derived from
1511 textlabels in the SVG file, as well as properties of the dataframe
(...)
1614
1615 """
1616 metadata = {
1617 "experimental": {
1618 "tags": self.tags,
1619 },
1620 "source": {
1621 "figure": self.figure_label,
1622 "curve": self.curve_label,
1623 },
1624 "figure description": {
1625 "version": 1,
1626 "type": "digitized",
1627 "simultaneous measurements": self.simultaneous_measurements,
1628 "measurement type": self.measurement_type,
-> 1629 "fields": self.figure_schema.to_dict()["fields"],
1630 "comment": self.comment,
1631 },
1632 "data description": {
1633 "version": 1,
1634 "type": "digitized",
1635 "measurement type": self.measurement_type,
1636 "fields": self.data_schema.to_dict()["fields"],
1637 },
1638 }
1640 if self.scan_rate is not None:
1641 metadata["figure description"].setdefault(
1642 "scan rate",
1643 {
(...)
1646 },
1647 )
File D:\Anaconda\envs\eme\lib\functools.py:981, in cached_property.__get__(self, instance, owner)
979 val = cache.get(self.attrname, _NOT_FOUND)
980 if val is _NOT_FOUND:
--> 981 val = self.func(instance)
982 try:
983 cache[self.attrname] = val
File D:\Anaconda\envs\eme\lib\site-packages\svgdigitizer\svgfigure.py:1386, in SVGFigure.figure_schema(self)
1308 r"""
1309 A frictionless `Schema` object, including a `Fields` object
1310 describing the axis of the original plot
(...)
1382
1383 """
1384 from frictionless import Schema
-> 1386 schema = Schema.from_descriptor(self.svgplot.figure_schema.to_dict())
1388 for field in schema.field_names:
1389 if not schema.get_field(field).custom["unit"]:
File D:\Anaconda\envs\eme\lib\site-packages\svgdigitizer\svgplot.py:1955, in SVGPlot.figure_schema(self)
1952 from frictionless import Pipeline, Resource, steps
1954 # infer the type of the fields from self.df
-> 1955 resource = Resource(self.df)
1956 resource.infer()
1958 orientations = {
1959 "horizontal": "x",
1960 "vertical": "y",
1961 }
File D:\Anaconda\envs\eme\lib\functools.py:981, in cached_property.__get__(self, instance, owner)
979 val = cache.get(self.attrname, _NOT_FOUND)
980 if val is _NOT_FOUND:
--> 981 val = self.func(instance)
982 try:
983 cache[self.attrname] = val
File D:\Anaconda\envs\eme\lib\site-packages\svgdigitizer\svgplot.py:2083, in SVGPlot.df(self)
1980 r"""
1981 Return the plot data as a dataframe of pairs (x, y).
1982
(...)
2080
2081 """
2082 if self.sampling_interval:
-> 2083 points = SVGPlot.sample_path(self.curve, self.sampling_interval)
2084 else:
2085 from .svg import LabeledPath
File D:\Anaconda\envs\eme\lib\functools.py:981, in cached_property.__get__(self, instance, owner)
979 val = cache.get(self.attrname, _NOT_FOUND)
980 if val is _NOT_FOUND:
--> 981 val = self.func(instance)
982 try:
983 cache[self.attrname] = val
File D:\Anaconda\envs\eme\lib\site-packages\svgdigitizer\svgplot.py:1471, in SVGPlot.curve(self)
1468 curves = self.labeled_paths["curve"]
1470 if len(curves) == 0:
-> 1471 raise SVGAnnotationError("No paths labeled 'curve:' found.")
1473 curves = [
1474 curve
1475 for curve in curves
1476 if self._curve is None or curve.label.curve_id == self._curve
1477 ]
1479 if len(curves) == 0:
SVGAnnotationError: No paths labeled 'curve:' found.
According to the error, the path in the SVG is not grouped with a text field labelled curve: identifier
, where the identifier can be chosen freely (as illustrated in the example in the documentation). You can also download the file from the documentation for reference on how to label a graph in the SVG.
I tried with the following :
https://www.tylervigen.com/spurious/correlation/image/2600_google-searches-for-cat-memes_correlates-with_automotive-recalls-for-issues-with-the-air-bags.svg
Got the exception above