Skip to content

Commit

Permalink
Fix: only pass color to plot.add when doing a 1d plot and raster pcol…
Browse files Browse the repository at this point in the history
…ormesh in pdf (#22)

* Fix: only pass color to plot.add when doing a 1d plot

Otherwise artifacts will be added to 2d plot this requires a hack

* Fix: rasterize pcolormesh plots in pdf

Significantly speeds up saving from 1m47s to 0.7s on my machine (100,5000) array. and makes pdfs that can be opened quickkly

* fix: only add grid to 1d plots in pdf
  • Loading branch information
jenshnielsen committed Nov 17, 2017
1 parent 7c69cc6 commit 95873e2
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions qcodes/utils/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from os import makedirs
import os
import logging
from copy import deepcopy

from qcodes.plots.pyqtgraph import QtPlot
from qcodes.plots.qcmatplotlib import MatPlot
Expand Down Expand Up @@ -162,9 +163,19 @@ def _save_individual_plots(data, inst_meas):
counter_two += 1
plot = MatPlot()
inst_meas_name = "{}_{}".format(i._instrument.name, name)
plot.add(getattr(data, inst_meas_name))
inst_meas_data = getattr(data, inst_meas_name)
# this is a hack because expand_trace works
# in place. Also it should probably * expand its args and kwargs. N
# Same below
inst_meas_data_copy = deepcopy(inst_meas_data)
inst_meta_data = {}
plot.expand_trace((inst_meas_data_copy,), kwargs=inst_meta_data)
if 'z' in inst_meta_data:
plot.add(inst_meas_data, rasterized=True)
else:
plot.add(inst_meas_data, color=color)
plot.subplots[0].grid()
plot.subplots[0].set_title(title)
plot.subplots[0].grid()
plot.save("{}_{:03d}.pdf".format(plot.get_default_title(), counter_two))
else:
# Step the color on all subplots no just on plots within the same axis/subplot
Expand All @@ -174,9 +185,16 @@ def _save_individual_plots(data, inst_meas):
plot = MatPlot()
# simple_parameter
inst_meas_name = "{}_{}".format(i._instrument.name, i.name)
plot.add(getattr(data, inst_meas_name))
inst_meas_data = getattr(data, inst_meas_name)
inst_meas_data_copy = deepcopy(inst_meas_data)
inst_meta_data = {}
plot.expand_trace((inst_meas_data_copy,), kwargs=inst_meta_data)
if 'z' in inst_meta_data:
plot.add(inst_meas_data, rasterized=True)
else:
plot.add(inst_meas_data, color=color)
plot.subplots[0].grid()
plot.subplots[0].set_title(title)
plot.subplots[0].grid()
plot.save("{}_{:03d}.pdf".format(plot.get_default_title(), counter_two))


Expand Down

0 comments on commit 95873e2

Please sign in to comment.