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

Saving composite as .svg #329

Open
drorcohengithub opened this issue Jun 12, 2019 · 0 comments
Open

Saving composite as .svg #329

drorcohengithub opened this issue Jun 12, 2019 · 0 comments

Comments

@drorcohengithub
Copy link
Contributor

drorcohengithub commented Jun 12, 2019

Hi guys,

How would I got about saving a figure generated using composting as svg ?

Below I try savefig() but it saves the layers (here ROI labels and borders) as images, so editing in an svg editor later (for example changing color/thickness/size of ROI borders or labels) is not possible. The colorbar is saved as a separate layer which can be edited.

Without compositing, I can use make_svg(), which saves the ROIs (labels and borders) as paths(?) in a layer, so they are still editable. I don't think make_svg() supports composting since it requires braindata as the input (doesn't work with a figure already plotted).

I use composting for the ROIs but also to hilight a specific voxels (for example in seed-based analysis) and sometimes to separately plot different parts of the data (using composite.add_data()).

Cheers

import cortex
import matplotlib.pyplot as plt
import numpy as np

# Create a random volume
volume = cortex.Volume.random(subject='S1', xfmname='fullhead')

# Create basic figure, with rois, labels, sulci all off
fig = cortex.quickflat.make_figure(volume,
                                   with_curvature=True,
                                   with_rois=False,
                                   with_labels=False,
                                   with_sulci=False)
# Add sulci in light yellow
_ = cortex.quickflat.composite.add_sulci(fig, volume,
                                         with_labels=False,
                                         linewidth=2,
                                         linecolor=(0.9, 0.85, 0.5))
# Add all rois, with a particular color scheme:
_ = cortex.quickflat.composite.add_rois(fig, volume,
                                        with_labels=False,
                                        linewidth=1,
                                        linecolor=(0.8, 0.8, 0.8))
# Highlight face- and body-selective ROIs:
_ = cortex.quickflat.composite.add_rois(fig, volume,
                                        roi_list=['FFA', 'EBA', 'OFA'],  # (This defaults to all rois if not specified)
                                        with_labels=True,
                                        linewidth=5,
                                        linecolor=(0.9, 0.5, 0.5),
                                        roifill=(0.9, 0.5, 0.5),
                                        fillalpha=0.35,
                                        dashes=(5, 3)                    # Dash length & gap btw dashes
                                        )
plt.savefig('chk.svg',format = 'svg')
plt.imshow() 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant