Python pandas.plotting.parallel_coordinates() Examples
The following are 20
code examples of pandas.plotting.parallel_coordinates().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pandas.plotting
, or try the search function
.
Example #1
Source File: test_misc.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def test_get_standard_colors_random_seed(self): # GH17525 df = DataFrame(np.zeros((10, 10))) # Make sure that the random seed isn't reset by _get_standard_colors plotting.parallel_coordinates(df, 0) rand1 = random.random() plotting.parallel_coordinates(df, 0) rand2 = random.random() assert rand1 != rand2 # Make sure it produces the same colors every time it's called from pandas.plotting._style import _get_standard_colors color1 = _get_standard_colors(1, color_type='random') color2 = _get_standard_colors(1, color_type='random') assert color1 == color2
Example #2
Source File: test_misc.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_get_standard_colors_random_seed(self): # GH17525 df = DataFrame(np.zeros((10, 10))) # Make sure that the random seed isn't reset by _get_standard_colors plotting.parallel_coordinates(df, 0) rand1 = random.random() plotting.parallel_coordinates(df, 0) rand2 = random.random() assert rand1 != rand2 # Make sure it produces the same colors every time it's called from pandas.plotting._style import _get_standard_colors color1 = _get_standard_colors(1, color_type='random') color2 = _get_standard_colors(1, color_type='random') assert color1 == color2
Example #3
Source File: test_misc.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_parallel_coordinates_with_sorted_labels(self): """ For #15908 """ from pandas.plotting import parallel_coordinates df = DataFrame({"feat": [i for i in range(30)], "class": [2 for _ in range(10)] + [3 for _ in range(10)] + [1 for _ in range(10)]}) ax = parallel_coordinates(df, 'class', sort_labels=True) polylines, labels = ax.get_legend_handles_labels() color_label_tuples = \ zip([polyline.get_color() for polyline in polylines], labels) ordered_color_label_tuples = sorted(color_label_tuples, key=lambda x: x[1]) prev_next_tupels = zip([i for i in ordered_color_label_tuples[0:-1]], [i for i in ordered_color_label_tuples[1:]]) for prev, nxt in prev_next_tupels: # labels and colors are ordered strictly increasing assert prev[1] < nxt[1] and prev[0] < nxt[0]
Example #4
Source File: test_misc.py From coffeegrindsize with MIT License | 6 votes |
def test_get_standard_colors_random_seed(self): # GH17525 df = DataFrame(np.zeros((10, 10))) # Make sure that the random seed isn't reset by _get_standard_colors plotting.parallel_coordinates(df, 0) rand1 = random.random() plotting.parallel_coordinates(df, 0) rand2 = random.random() assert rand1 != rand2 # Make sure it produces the same colors every time it's called from pandas.plotting._style import _get_standard_colors color1 = _get_standard_colors(1, color_type='random') color2 = _get_standard_colors(1, color_type='random') assert color1 == color2
Example #5
Source File: test_misc.py From coffeegrindsize with MIT License | 6 votes |
def test_parallel_coordinates_with_sorted_labels(self): """ For #15908 """ from pandas.plotting import parallel_coordinates df = DataFrame({"feat": [i for i in range(30)], "class": [2 for _ in range(10)] + [3 for _ in range(10)] + [1 for _ in range(10)]}) ax = parallel_coordinates(df, 'class', sort_labels=True) polylines, labels = ax.get_legend_handles_labels() color_label_tuples = \ zip([polyline.get_color() for polyline in polylines], labels) ordered_color_label_tuples = sorted(color_label_tuples, key=lambda x: x[1]) prev_next_tupels = zip([i for i in ordered_color_label_tuples[0:-1]], [i for i in ordered_color_label_tuples[1:]]) for prev, nxt in prev_next_tupels: # labels and colors are ordered strictly increasing assert prev[1] < nxt[1] and prev[0] < nxt[0]
Example #6
Source File: test_misc.py From elasticintel with GNU General Public License v3.0 | 6 votes |
def test_get_standard_colors_random_seed(self): # GH17525 df = DataFrame(np.zeros((10, 10))) # Make sure that the random seed isn't reset by _get_standard_colors plotting.parallel_coordinates(df, 0) rand1 = random.random() plotting.parallel_coordinates(df, 0) rand2 = random.random() assert rand1 != rand2 # Make sure it produces the same colors every time it's called from pandas.plotting._style import _get_standard_colors color1 = _get_standard_colors(1, color_type='random') color2 = _get_standard_colors(1, color_type='random') assert color1 == color2
Example #7
Source File: test_misc.py From elasticintel with GNU General Public License v3.0 | 6 votes |
def test_parallel_coordinates_with_sorted_labels(self): """ For #15908 """ from pandas.plotting import parallel_coordinates df = DataFrame({"feat": [i for i in range(30)], "class": [2 for _ in range(10)] + [3 for _ in range(10)] + [1 for _ in range(10)]}) ax = parallel_coordinates(df, 'class', sort_labels=True) polylines, labels = ax.get_legend_handles_labels() color_label_tuples = \ zip([polyline.get_color() for polyline in polylines], labels) ordered_color_label_tuples = sorted(color_label_tuples, key=lambda x: x[1]) prev_next_tupels = zip([i for i in ordered_color_label_tuples[0:-1]], [i for i in ordered_color_label_tuples[1:]]) for prev, nxt in prev_next_tupels: # lables and colors are ordered strictly increasing assert prev[1] < nxt[1] and prev[0] < nxt[0]
Example #8
Source File: test_misc.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def test_parallel_coordinates_with_sorted_labels(self): """ For #15908 """ from pandas.plotting import parallel_coordinates df = DataFrame({"feat": [i for i in range(30)], "class": [2 for _ in range(10)] + [3 for _ in range(10)] + [1 for _ in range(10)]}) ax = parallel_coordinates(df, 'class', sort_labels=True) polylines, labels = ax.get_legend_handles_labels() color_label_tuples = \ zip([polyline.get_color() for polyline in polylines], labels) ordered_color_label_tuples = sorted(color_label_tuples, key=lambda x: x[1]) prev_next_tupels = zip([i for i in ordered_color_label_tuples[0:-1]], [i for i in ordered_color_label_tuples[1:]]) for prev, nxt in prev_next_tupels: # labels and colors are ordered strictly increasing assert prev[1] < nxt[1] and prev[0] < nxt[0]
Example #9
Source File: from_neighborlist.py From CatLearn with GNU General Public License v3.0 | 6 votes |
def parallel_plot(data, num=None): plt.figure(num=num, figsize=(50,25)) ax = parallel_coordinates( data, 'target', colormap=cmap, axvlines=False) plt.legend().set_visible(False) plt.grid(False) ax.xaxis.set_ticks_position('none') for label in ax.get_xticklabels(): label.set_fontname('Arial') label.set_fontsize(0) for label in ax.get_yticklabels(): label.set_fontname('Arial') label.set_fontsize(30) axis_font = {'fontname':'Arial', 'size':'35'} plt.ylabel("Numeric Representation", **axis_font) plt.xlabel("Fingerprint", **axis_font) # In[11]:
Example #10
Source File: from_coordinates.py From CatLearn with GNU General Public License v3.0 | 6 votes |
def parallel_plot(data, num=None): plt.figure(num=num, figsize=(50,25)) ax = parallel_coordinates( data, 'target', colormap=cmap, axvlines=False) plt.legend().set_visible(False) plt.grid(False) ax.xaxis.set_ticks_position('none') for label in ax.get_xticklabels(): label.set_fontname('Arial') label.set_fontsize(0) for label in ax.get_yticklabels(): label.set_fontname('Arial') label.set_fontsize(30) axis_font = {'fontname':'Arial', 'size':'35'} plt.ylabel("Numeric Representation", **axis_font) plt.xlabel("Fingerprint", **axis_font) # We can then plot the original unscaled data. # In[10]:
Example #11
Source File: test_misc.py From vnpy_crypto with MIT License | 6 votes |
def test_get_standard_colors_random_seed(self): # GH17525 df = DataFrame(np.zeros((10, 10))) # Make sure that the random seed isn't reset by _get_standard_colors plotting.parallel_coordinates(df, 0) rand1 = random.random() plotting.parallel_coordinates(df, 0) rand2 = random.random() assert rand1 != rand2 # Make sure it produces the same colors every time it's called from pandas.plotting._style import _get_standard_colors color1 = _get_standard_colors(1, color_type='random') color2 = _get_standard_colors(1, color_type='random') assert color1 == color2
Example #12
Source File: test_misc.py From vnpy_crypto with MIT License | 6 votes |
def test_parallel_coordinates_with_sorted_labels(self): """ For #15908 """ from pandas.plotting import parallel_coordinates df = DataFrame({"feat": [i for i in range(30)], "class": [2 for _ in range(10)] + [3 for _ in range(10)] + [1 for _ in range(10)]}) ax = parallel_coordinates(df, 'class', sort_labels=True) polylines, labels = ax.get_legend_handles_labels() color_label_tuples = \ zip([polyline.get_color() for polyline in polylines], labels) ordered_color_label_tuples = sorted(color_label_tuples, key=lambda x: x[1]) prev_next_tupels = zip([i for i in ordered_color_label_tuples[0:-1]], [i for i in ordered_color_label_tuples[1:]]) for prev, nxt in prev_next_tupels: # labels and colors are ordered strictly increasing assert prev[1] < nxt[1] and prev[0] < nxt[0]
Example #13
Source File: test_misc.py From recruit with Apache License 2.0 | 6 votes |
def test_get_standard_colors_random_seed(self): # GH17525 df = DataFrame(np.zeros((10, 10))) # Make sure that the random seed isn't reset by _get_standard_colors plotting.parallel_coordinates(df, 0) rand1 = random.random() plotting.parallel_coordinates(df, 0) rand2 = random.random() assert rand1 != rand2 # Make sure it produces the same colors every time it's called from pandas.plotting._style import _get_standard_colors color1 = _get_standard_colors(1, color_type='random') color2 = _get_standard_colors(1, color_type='random') assert color1 == color2
Example #14
Source File: test_misc.py From recruit with Apache License 2.0 | 6 votes |
def test_parallel_coordinates_with_sorted_labels(self): """ For #15908 """ from pandas.plotting import parallel_coordinates df = DataFrame({"feat": [i for i in range(30)], "class": [2 for _ in range(10)] + [3 for _ in range(10)] + [1 for _ in range(10)]}) ax = parallel_coordinates(df, 'class', sort_labels=True) polylines, labels = ax.get_legend_handles_labels() color_label_tuples = \ zip([polyline.get_color() for polyline in polylines], labels) ordered_color_label_tuples = sorted(color_label_tuples, key=lambda x: x[1]) prev_next_tupels = zip([i for i in ordered_color_label_tuples[0:-1]], [i for i in ordered_color_label_tuples[1:]]) for prev, nxt in prev_next_tupels: # labels and colors are ordered strictly increasing assert prev[1] < nxt[1] and prev[0] < nxt[0]
Example #15
Source File: test_misc.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 4 votes |
def test_parallel_coordinates(self, iris): from pandas.plotting import parallel_coordinates from matplotlib import cm df = iris ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name') nlines = len(ax.get_lines()) nxticks = len(ax.xaxis.get_ticklabels()) rgba = ('#556270', '#4ECDC4', '#C7F464') ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name', color=rgba) self._check_colors( ax.get_lines()[:10], linecolors=rgba, mapping=df['Name'][:10]) cnames = ['dodgerblue', 'aquamarine', 'seagreen'] ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name', color=cnames) self._check_colors( ax.get_lines()[:10], linecolors=cnames, mapping=df['Name'][:10]) ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name', colormap=cm.jet) cmaps = lmap(cm.jet, np.linspace(0, 1, df['Name'].nunique())) self._check_colors( ax.get_lines()[:10], linecolors=cmaps, mapping=df['Name'][:10]) ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name', axvlines=False) assert len(ax.get_lines()) == (nlines - nxticks) colors = ['b', 'g', 'r'] df = DataFrame({"A": [1, 2, 3], "B": [1, 2, 3], "C": [1, 2, 3], "Name": colors}) ax = parallel_coordinates(df, 'Name', color=colors) handles, labels = ax.get_legend_handles_labels() self._check_colors(handles, linecolors=colors) with tm.assert_produces_warning(FutureWarning): parallel_coordinates(data=df, class_column='Name') with tm.assert_produces_warning(FutureWarning): parallel_coordinates(df, 'Name', colors=colors) # not sure if this is indicative of a problem
Example #16
Source File: test_misc.py From recruit with Apache License 2.0 | 4 votes |
def test_parallel_coordinates(self, iris): from pandas.plotting import parallel_coordinates from matplotlib import cm df = iris ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name') nlines = len(ax.get_lines()) nxticks = len(ax.xaxis.get_ticklabels()) rgba = ('#556270', '#4ECDC4', '#C7F464') ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name', color=rgba) self._check_colors( ax.get_lines()[:10], linecolors=rgba, mapping=df['Name'][:10]) cnames = ['dodgerblue', 'aquamarine', 'seagreen'] ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name', color=cnames) self._check_colors( ax.get_lines()[:10], linecolors=cnames, mapping=df['Name'][:10]) ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name', colormap=cm.jet) cmaps = lmap(cm.jet, np.linspace(0, 1, df['Name'].nunique())) self._check_colors( ax.get_lines()[:10], linecolors=cmaps, mapping=df['Name'][:10]) ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name', axvlines=False) assert len(ax.get_lines()) == (nlines - nxticks) colors = ['b', 'g', 'r'] df = DataFrame({"A": [1, 2, 3], "B": [1, 2, 3], "C": [1, 2, 3], "Name": colors}) ax = parallel_coordinates(df, 'Name', color=colors) handles, labels = ax.get_legend_handles_labels() self._check_colors(handles, linecolors=colors) with tm.assert_produces_warning(FutureWarning): parallel_coordinates(data=df, class_column='Name') with tm.assert_produces_warning(FutureWarning): parallel_coordinates(df, 'Name', colors=colors) # not sure if this is indicative of a problem
Example #17
Source File: test_misc.py From elasticintel with GNU General Public License v3.0 | 4 votes |
def test_parallel_coordinates(self): from pandas.plotting import parallel_coordinates from matplotlib import cm df = self.iris ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name') nlines = len(ax.get_lines()) nxticks = len(ax.xaxis.get_ticklabels()) rgba = ('#556270', '#4ECDC4', '#C7F464') ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name', color=rgba) self._check_colors( ax.get_lines()[:10], linecolors=rgba, mapping=df['Name'][:10]) cnames = ['dodgerblue', 'aquamarine', 'seagreen'] ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name', color=cnames) self._check_colors( ax.get_lines()[:10], linecolors=cnames, mapping=df['Name'][:10]) ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name', colormap=cm.jet) cmaps = lmap(cm.jet, np.linspace(0, 1, df['Name'].nunique())) self._check_colors( ax.get_lines()[:10], linecolors=cmaps, mapping=df['Name'][:10]) ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name', axvlines=False) assert len(ax.get_lines()) == (nlines - nxticks) colors = ['b', 'g', 'r'] df = DataFrame({"A": [1, 2, 3], "B": [1, 2, 3], "C": [1, 2, 3], "Name": colors}) ax = parallel_coordinates(df, 'Name', color=colors) handles, labels = ax.get_legend_handles_labels() self._check_colors(handles, linecolors=colors) with tm.assert_produces_warning(FutureWarning): parallel_coordinates(data=df, class_column='Name') with tm.assert_produces_warning(FutureWarning): parallel_coordinates(df, 'Name', colors=colors)
Example #18
Source File: test_misc.py From coffeegrindsize with MIT License | 4 votes |
def test_parallel_coordinates(self, iris): from pandas.plotting import parallel_coordinates from matplotlib import cm df = iris ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name') nlines = len(ax.get_lines()) nxticks = len(ax.xaxis.get_ticklabels()) rgba = ('#556270', '#4ECDC4', '#C7F464') ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name', color=rgba) self._check_colors( ax.get_lines()[:10], linecolors=rgba, mapping=df['Name'][:10]) cnames = ['dodgerblue', 'aquamarine', 'seagreen'] ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name', color=cnames) self._check_colors( ax.get_lines()[:10], linecolors=cnames, mapping=df['Name'][:10]) ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name', colormap=cm.jet) cmaps = lmap(cm.jet, np.linspace(0, 1, df['Name'].nunique())) self._check_colors( ax.get_lines()[:10], linecolors=cmaps, mapping=df['Name'][:10]) ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name', axvlines=False) assert len(ax.get_lines()) == (nlines - nxticks) colors = ['b', 'g', 'r'] df = DataFrame({"A": [1, 2, 3], "B": [1, 2, 3], "C": [1, 2, 3], "Name": colors}) ax = parallel_coordinates(df, 'Name', color=colors) handles, labels = ax.get_legend_handles_labels() self._check_colors(handles, linecolors=colors) with tm.assert_produces_warning(FutureWarning): parallel_coordinates(data=df, class_column='Name') with tm.assert_produces_warning(FutureWarning): parallel_coordinates(df, 'Name', colors=colors) # not sure if this is indicative of a problem
Example #19
Source File: test_misc.py From vnpy_crypto with MIT License | 4 votes |
def test_parallel_coordinates(self, iris): from pandas.plotting import parallel_coordinates from matplotlib import cm df = iris ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name') nlines = len(ax.get_lines()) nxticks = len(ax.xaxis.get_ticklabels()) rgba = ('#556270', '#4ECDC4', '#C7F464') ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name', color=rgba) self._check_colors( ax.get_lines()[:10], linecolors=rgba, mapping=df['Name'][:10]) cnames = ['dodgerblue', 'aquamarine', 'seagreen'] ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name', color=cnames) self._check_colors( ax.get_lines()[:10], linecolors=cnames, mapping=df['Name'][:10]) ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name', colormap=cm.jet) cmaps = lmap(cm.jet, np.linspace(0, 1, df['Name'].nunique())) self._check_colors( ax.get_lines()[:10], linecolors=cmaps, mapping=df['Name'][:10]) ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name', axvlines=False) assert len(ax.get_lines()) == (nlines - nxticks) colors = ['b', 'g', 'r'] df = DataFrame({"A": [1, 2, 3], "B": [1, 2, 3], "C": [1, 2, 3], "Name": colors}) ax = parallel_coordinates(df, 'Name', color=colors) handles, labels = ax.get_legend_handles_labels() self._check_colors(handles, linecolors=colors) with tm.assert_produces_warning(FutureWarning): parallel_coordinates(data=df, class_column='Name') with tm.assert_produces_warning(FutureWarning): parallel_coordinates(df, 'Name', colors=colors)
Example #20
Source File: test_misc.py From twitter-stock-recommendation with MIT License | 4 votes |
def test_parallel_coordinates(self, iris): from pandas.plotting import parallel_coordinates from matplotlib import cm df = iris ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name') nlines = len(ax.get_lines()) nxticks = len(ax.xaxis.get_ticklabels()) rgba = ('#556270', '#4ECDC4', '#C7F464') ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name', color=rgba) self._check_colors( ax.get_lines()[:10], linecolors=rgba, mapping=df['Name'][:10]) cnames = ['dodgerblue', 'aquamarine', 'seagreen'] ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name', color=cnames) self._check_colors( ax.get_lines()[:10], linecolors=cnames, mapping=df['Name'][:10]) ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name', colormap=cm.jet) cmaps = lmap(cm.jet, np.linspace(0, 1, df['Name'].nunique())) self._check_colors( ax.get_lines()[:10], linecolors=cmaps, mapping=df['Name'][:10]) ax = _check_plot_works(parallel_coordinates, frame=df, class_column='Name', axvlines=False) assert len(ax.get_lines()) == (nlines - nxticks) colors = ['b', 'g', 'r'] df = DataFrame({"A": [1, 2, 3], "B": [1, 2, 3], "C": [1, 2, 3], "Name": colors}) ax = parallel_coordinates(df, 'Name', color=colors) handles, labels = ax.get_legend_handles_labels() self._check_colors(handles, linecolors=colors) with tm.assert_produces_warning(FutureWarning): parallel_coordinates(data=df, class_column='Name') with tm.assert_produces_warning(FutureWarning): parallel_coordinates(df, 'Name', colors=colors)