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

Remove the scatter graph.

parent 55d326ae
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
""" """
import json import json
import matplotlib as mpl import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd import pandas as pd
from gluon import current from gluon import current
...@@ -242,9 +240,6 @@ class Graph(object): ...@@ -242,9 +240,6 @@ class Graph(object):
elif kind in ("area", "line"): elif kind in ("area", "line"):
func = Graph.line_like func = Graph.line_like
elif kind in ("scatter"):
func = Graph.point_like
# produce the plot without summary rows or columns # produce the plot without summary rows or columns
self.ax = func(metric2d.df0, self.ax = func(metric2d.df0,
group_field_x, group_field_x,
...@@ -356,74 +351,6 @@ class Graph(object): ...@@ -356,74 +351,6 @@ class Graph(object):
return ax 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): def _savefig(self, fmt):
"""Save the figure as a string. """Save the figure as a string.
......
...@@ -61,8 +61,7 @@ Ext.define("Event.form.field.Graph", { ...@@ -61,8 +61,7 @@ Ext.define("Event.form.field.Graph", {
kind: ["area", kind: ["area",
"bar", "bar",
"barh", "barh",
"line", "line"
"scatter"
], ],
// private properties for internationalization // 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