Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature-request : export as svg or pdf #37

Open
Mriv31 opened this issue Feb 20, 2022 · 9 comments
Open

feature-request : export as svg or pdf #37

Mriv31 opened this issue Feb 20, 2022 · 9 comments

Comments

@Mriv31
Copy link

Mriv31 commented Feb 20, 2022

A great feature would be to add the possibility to export a panel in a PDF or a SVG file !

@rossant
Copy link
Contributor

rossant commented Feb 21, 2022

A long-term plan with Datoviz is to make a GPU rendering backend, leaving to other projects (such as the future VisPy 2.0 for which work has just started) the high-level specification of the scene. Export to vector formats would then be part of these other projects and not Datoviz itself.

@Mriv31
Copy link
Author

Mriv31 commented Feb 22, 2022

Ok, then I need to work on the interactivity of the program and keep performing export with matplotlib.
The goal would then be to have an interaction between a highly interactive scripting interface, like a Jupyter notebook, and the highly efficient and interactive visualization library datoviz.
We would be able to smoothly navigate in the data and visualize them using datoviz and when you find an interesting feature, you select the points you are interested in, by clicking or pressing a key, you transfer the reference to the current visible part of the data to the notebook, eventually save the data to the disk, and then perform figure editing with matplotlib in the notebook.
I still wasn't able to have datoviz working in a Jupyter notebook, though. Any idea why ?
When executing datoviz run(), in a Jupyter notebook, the Python kernel crashes and I get
ERROR:root:Invalid GUI request 'datoviz', valid ones are:dict_keys(['inline', 'nbagg', 'notebook', 'ipympl', 'widget', None, 'qt4', 'qt', 'qt5', 'wx', 'tk', 'gtk', 'gtk3', 'osx', 'asyncio'])
Thank you !!

@rossant
Copy link
Contributor

rossant commented Feb 22, 2022

Jupyter is not well supported yet, unfortunately. This is a major objective of the next version which is still in development.

@Mriv31
Copy link
Author

Mriv31 commented Feb 24, 2022

If you force to run in asyncio with Jupyter, it works, I don't really understand why : https://drive.google.com/file/d/1khMcT67qXGDz1SPJ07y3IisDY0RtlVd6/view?usp=sharing
Of course it still runs in a separate window, but I can interact with it and dynamically add data/read data from the jupyter notebook. For me this is all I need, I'm very happy.
Still, asyncio throws a runtime error (see video), but it does not affect how the program works !
Is there an option to decrease the refresh rate when the image is not changing ? In order to redue the load when there is no need to refresh ? Datoviz is running at 100 fps even when nothing changes !

@Mriv31
Copy link
Author

Mriv31 commented Feb 24, 2022

The error (shown in the output of the run() function, hidden in my video) is 👍

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-27-ec9775ede022> in <module>
----> 1 run()

/media/martin/Data/Documents/Post-Doc/datoviz/datoviz/bindings/cython/datoviz/__init__.py in run(n_frames, event_loop, **kwargs)
    184     event_loop = event_loop or 'native'
    185     if event_loop == 'ipython' or is_interactive():
--> 186         run_asyncio(n_frames)
    187 
    188 

/media/martin/Data/Documents/Post-Doc/datoviz/datoviz/bindings/cython/datoviz/__init__.py in run_asyncio(n_frames, **kwargs)
    163 
    164     try:
--> 165         _ASYNCIO_LOOP.run_until_complete(task)
    166     except asyncio.CancelledError:
    167         pass

/usr/lib/python3.8/asyncio/base_events.py in run_until_complete(self, future)
    590         """
    591         self._check_closed()
--> 592         self._check_running()
    593 
    594         new_task = not futures.isfuture(future)

/usr/lib/python3.8/asyncio/base_events.py in _check_running(self)
    550     def _check_running(self):
    551         if self.is_running():
--> 552             raise RuntimeError('This event loop is already running')
    553         if events._get_running_loop() is not None:
    554             raise RuntimeError(

RuntimeError: This event loop is already running

@rossant
Copy link
Contributor

rossant commented Feb 24, 2022

Can you try passing show_fps=False to canvas()?

Good thing if asyncio is working. I wouldn't worry much about the error message, the asyncio event loop is still quite experimental.

@Mriv31
Copy link
Author

Mriv31 commented Feb 24, 2022

Show_fps does not seem to affect the GPU usage for my code (default panel and scene parameters, 2 visuals, 1 "markers" and 1 "line_strip". (between 70% and 80% for the same "constant" graph, whether show_fps is false or true). I also tried to disconnect all events, it does not change.

However, I also tried with the example france.py and here it affects (29% GPU usage with show_fps = false, 70% when true)
I use nvidia-smi to assess GPU Utilisation.

Thu Feb 24 08:53:40 2022       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.86       Driver Version: 470.86       CUDA Version: 11.4     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  Off  | 00000000:02:00.0 Off |                  N/A |
| N/A   65C    P0    N/A /  N/A |    121MiB /  2002MiB |     73%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A     25110    C+G   python3                           119MiB |
+-----------------------------------------------------------------------------+

@rossant
Copy link
Contributor

rossant commented Feb 24, 2022

show_fps=False should enable vertical synchronization, which will limit the framerate to 60 FPS. This framerate may still be too high for your computer, though. Maybe Datoviz should offer an option to artificially reduce the framerate even further. You could also check whether your nvidia card has settings that would allow you to reduce the framerate (google "half refresh rate" for example)

@Mriv31
Copy link
Author

Mriv31 commented Feb 24, 2022

That makes sense. My own plot was very large so was already updating at FPS smaller than 60, hence no difference, while the France.py example was updating at a higher FPS. Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants