Skip to content
Snippets Groups Projects
Commit 5f41614a authored by Germain Clavier's avatar Germain Clavier
Browse files

Added symbols (circles only) to qp. Not yet compatible with error bars.

parent 7847911a
No related branches found
No related tags found
No related merge requests found
......@@ -15,9 +15,7 @@ import povray as pov
from itertools import cycle
import numpy as np
import scipy as sp
from scipy.signal import savgol_filter
from scipy.interpolate import interp1d
from matplotlib import pyplot as plt
# plt.rcParams.update({'lines.markeredgewidth': 4})
......@@ -62,7 +60,7 @@ def read_columns(fle, columns_list, fmt, skip, xsca, ysca, sg):
return output
def plot_sep_col(data, colors, fmt, is_log, legend):
def plot_sep_col(data, colors, fmt, is_log, legend, sy):
'''
Makes separated ordered columns
wise: all 1:2 together, all 1:3 together
......@@ -89,6 +87,10 @@ def plot_sep_col(data, colors, fmt, is_log, legend):
break
plot_nb = len(columns)
if sy:
symbols = {'linestyle': "None", 'marker': "o"}
else:
symbols = {'linestyle': '-', 'marker': "None"}
if plot_nb % 3 == 0:
fig, axes = plt.subplots(plot_nb//3, 3, sharex=True, figsize=(20, 10))
elif plot_nb % 2 == 0:
......@@ -111,7 +113,8 @@ def plot_sep_col(data, colors, fmt, is_log, legend):
y_data = subdata[3]
if fmt == 'xy':
ax.plot(x_data, y_data,
label=lab, color=color
label=lab, color=color,
**symbols
)
elif fmt == 'xydy':
dy = subdata[4]
......@@ -125,11 +128,6 @@ def plot_sep_col(data, colors, fmt, is_log, legend):
alpha=0.2, edgecolor=color, facecolor=color,
linewidth=0
)
# ax.errorbar(x_data, y_data,
# yerr=dy,
# capsize=4, capthick=2,
# label=lab, color=color
# )
elif fmt == 'xydx':
dx = subdata[4]
ax.errorbar(x_data, y_data,
......@@ -149,7 +147,6 @@ def plot_sep_col(data, colors, fmt, is_log, legend):
ax.set_xscale('log')
if is_log[1]:
ax.set_yscale('log')
# color = next(color_iter)
if legend:
ncol = max([1, len(data)//3])
ax.legend(loc='upper left', ncol=ncol)
......@@ -158,8 +155,12 @@ def plot_sep_col(data, colors, fmt, is_log, legend):
return [fig, axes]
def plot_sep_fil(data, colors, fmt, is_log, legend):
def plot_sep_fil(data, colors, fmt, is_log, legend, sy):
plot_nb = len(data)
if sy:
symbols = {'linestyle': "None", 'marker': "o"}
else:
symbols = {'linestyle': '-', 'marker': "None"}
if plot_nb % 3 == 0:
fig, axes = plt.subplots(plot_nb//3, 3, sharex=True, figsize=(20, 10))
elif plot_nb % 2 == 0:
......@@ -178,7 +179,8 @@ def plot_sep_fil(data, colors, fmt, is_log, legend):
y_data = subdata[3]
if fmt == 'xy':
ax.plot(x_data, y_data,
label=lab, color=color
label=lab, color=color,
**symbols
)
elif fmt == 'xydy':
dy = subdata[4]
......@@ -192,11 +194,6 @@ def plot_sep_fil(data, colors, fmt, is_log, legend):
alpha=0.2, edgecolor=color, facecolor=color,
linewidth=0
)
# ax.errorbar(x_data, y_data,
# yerr=dy,
# capsize=4, capthick=2,
# label=lab, color=color
# )
elif fmt == 'xydx':
dx = subdata[4]
ax.errorbar(x_data, y_data,
......@@ -216,7 +213,6 @@ def plot_sep_fil(data, colors, fmt, is_log, legend):
ax.set_xscale('log')
if is_log[1]:
ax.set_yscale('log')
# color = next(color_iter)
if legend:
ncol = max([1, len(data)//3])
ax.legend(loc='upper left', ncol=ncol)
......@@ -225,10 +221,14 @@ def plot_sep_fil(data, colors, fmt, is_log, legend):
return [fig, axes]
def plot_data(data, colors, fmt, is_log, legend, names):
def plot_data(data, colors, fmt, is_log, legend, names, sy):
color_iter = cycle(colors)
plt.figure(figsize=(40, 30))
namelist = iter(names)
if sy:
symbols = {'linestyle': "None", 'marker': "o"}
else:
symbols = {'linestyle': '-', 'marker': "None"}
for d in data:
color = next(color_iter)
try:
......@@ -248,7 +248,8 @@ def plot_data(data, colors, fmt, is_log, legend, names):
y_data = subdata[3]
if fmt == 'xy':
plt.plot(x_data, y_data,
label=lab, color=color
label=lab, color=color,
**symbols
)
elif fmt == 'xydy':
dy = subdata[4]
......@@ -262,11 +263,6 @@ def plot_data(data, colors, fmt, is_log, legend, names):
alpha=0.2, edgecolor=color, facecolor=color,
linewidth=0
)
# plt.errorbar(x_data, y_data,
# yerr=dy,
# capsize=4, capthick=2,
# label=lab, color=color
# )
elif fmt == 'xydx':
dx = subdata[4]
plt.errorbar(x_data, y_data,
......@@ -286,9 +282,7 @@ def plot_data(data, colors, fmt, is_log, legend, names):
plt.xscale('log')
if is_log[1]:
plt.yscale('log')
# color = next(color_iter)
if legend:
# plt.legend(loc='upper left')
ncol = max([1, len(data)//3])
plt.legend(ncol=ncol)
return
......@@ -299,14 +293,15 @@ def main():
Main function.
'''
parser = ap.ArgumentParser(description='Script to plot a list of files.')
parser.add_argument('-v', '--verbose', dest='verbosity',
action='store_true', help='Verbosity.')
parser.add_argument('-sf', '--separated-files', dest='sf',
default=False, action='store_true',
help='Plot in separated windows based on filename. [default = False]')
action='store_true',
help='Plot in separated windows based on filename.')
parser.add_argument('-sc', '--separated-columns', dest='sc',
default=False, action='store_true',
help='Plot in separated windows based on columns. [default = False]')
action='store_true',
help='Plot in separated windows based on columns.')
parser.add_argument('-sy', '--symbols', dest='sy',
action='store_true',
help='Use symbols and not lines')
parser.add_argument('-fmt', '--fmt', dest='fmt',
default='xy',
help='Format of the plot (xy, xydy, xydxdy, xydx). [default = xy]')
......@@ -349,9 +344,9 @@ def main():
args = parser.parse_args()
verbose = args.verbosity
sep_files = args.sf
sep_col = args.sc
sy = args.sy
fmt = args.fmt
inpt = args.input
graph_title = args.ttl
......@@ -433,11 +428,11 @@ def main():
data.append(read_columns(fle, columns_list, fmt, skip, xsca, ysca, sg))
if sep_col:
fig, axes = plot_sep_col(data, colors, fmt, is_log, legend)
fig, axes = plot_sep_col(data, colors, fmt, is_log, legend, sy)
elif sep_files:
fig, axes = plot_sep_fil(data, colors, fmt, is_log, legend)
fig, axes = plot_sep_fil(data, colors, fmt, is_log, legend, sy)
else:
plot_data(data, colors, fmt, is_log, legend, names)
plot_data(data, colors, fmt, is_log, legend, names, sy)
plt.xlabel(xlab)
plt.ylabel(ylab)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment