Commit 9b0a8ba0 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Remove the scatter graph.

parent 55d326ae
......@@ -4,8 +4,6 @@
"""
import json
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from gluon import current
......@@ -242,9 +240,6 @@ class Graph(object):
elif kind in ("area", "line"):
func = Graph.line_like
elif kind in ("scatter"):
func = Graph.point_like
# produce the plot without summary rows or columns
self.ax = func(metric2d.df0,
group_field_x,
......@@ -356,74 +351,6 @@ class Graph(object):
return ax
@staticmethod
def point_like(df,
group_field_x,
group_field_y,
metric_field_z,
config_graph):
"""Produce scatter plot
Args:
df (pandas.DataFrame):
group_field_x (str):
group_field_y (str):
metric_field_z (str):
config_graph (dict): keyword argument of the DataFrame.plot method
Returns:
matplotlib.axes or None
"""
# clean the configuration of the graph
del config_graph[u"colormap"]
del config_graph[u"stacked"]
del config_graph[u"width"]
# prepare the DataFrame
df1 = df.transpose()
if group_field_y in df.columns:
df1.columns = df1.loc[group_field_y, :]
df1 = df1[df1.index != group_field_y]
df1 = df1.reset_index()
# graph
# colorize the point, one color per columns
# colors come from the Spectral colormap
colors = plt.cm.Spectral(np.linspace(0., 1., df1.columns.size))
ax, columns = None, df1.columns
for i, col in enumerate(columns):
if col == group_field_x:
continue
ax = df1.plot(ax=ax,
color=colors[i],
label=columns[i],
x=group_field_x,
y=col,
**config_graph)
# tick and axis labels
xlabel, ylabel = group_field_x, metric_field_z
if group_field_x == "year":
ax.xaxis.set_major_formatter(mpl.ticker.FormatStrFormatter("%i"))
if group_field_y == "year":
ax.yaxis.set_major_formatter(mpl.ticker.FormatStrFormatter("%i"))
ticks_and_labels(ax, xlabel, ylabel)
# legend
legend = ax.get_legend()
if legend is not None:
ax.get_legend().set_title("")
return ax
def _savefig(self, fmt):
"""Save the figure as a string.
......
......@@ -61,8 +61,7 @@ Ext.define("Event.form.field.Graph", {
kind: ["area",
"bar",
"barh",
"line",
"scatter"
"line"
],
// private properties for internationalization
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment