Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Violin #471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Kully merged 28 commits into master from Violin
Jun 14, 2016
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
651e725
Changed tools.py
Kully May 18, 2016
b4eb690
Updated tools.py again
Kully May 18, 2016
2530527
...
Kully May 18, 2016
85710a6
Improved tools.py
Kully May 20, 2016
352d233
First PR for Violin: colorscaling, visible colorscale, all color-type...
Kully May 20, 2016
e29e7d3
Updated default-schema
Kully Jun 2, 2016
bde9a7c
Updated color parsing functions
Kully Jun 2, 2016
4257ed6
Added changes
Kully Jun 2, 2016
b0ff4d2
...
Kully Jun 3, 2016
06d685d
added more things
Kully Jun 3, 2016
13b5ba7
more
Kully Jun 5, 2016
a69c4bd
Violin with qualitative colors//updated tests
Kully Jun 5, 2016
a6ce8e3
re-did tests
Kully Jun 5, 2016
9a20ece
Add a description line
Kully Jun 5, 2016
d3059e0
added tests//added group labels to plots//edited main doc string
Kully Jun 6, 2016
ce6f83a
Added/updated doc string examples
Kully Jun 6, 2016
164a9c6
accurate colorscale max/min labels
Kully Jun 6, 2016
4abec6e
Made error messages more legible
Kully Jun 8, 2016
6bd112b
Moved PLOTLY_SCALES to top of file
Kully Jun 8, 2016
5900590
...
Kully Jun 8, 2016
11da292
..
Kully Jun 8, 2016
536ab35
wrote method for dealing with different color formats (eg. list, tupl...
Kully Jun 8, 2016
4904ac5
added color_parser function//removed dictionary capbilities
Kully Jun 10, 2016
d0f55cf
Replaced DEFAULT_FILLCOLOR with fillcolor param in functions
Kully Jun 13, 2016
4a954e1
Merged master into Violin
Kully Jun 13, 2016
d319448
Made tests compatible with color_parser code
Kully Jun 13, 2016
303385d
Replaced new color_parser function into scatterplot_theme
Kully Jun 14, 2016
c24b374
Removed commented out code and removed brackets from 'if colors[index...
Kully Jun 14, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wrote method for dealing with different color formats (eg. list, tupl...
...e, str, etc)
  • Loading branch information
Kully committed Jun 8, 2016
commit 536ab3575868aae9cac3f7fe8926b599f71187ef
140 changes: 48 additions & 92 deletions plotly/tools.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2267,6 +2267,30 @@ def _find_intermediate_color(lowcolor, highcolor, intermed):
lowcolor[2] + intermed * diff_2)
return inter_colors

@staticmethod
def _color_parser(colors, function):
"""
Takes color(s) and a function and applys the function on the color(s)

In particular, this function identifies whether the given color object
is an iterable or not and applies the given color-parsing function to
the color or iterable of colors

"""
if hasattr(colors[0], '__iter__') or isinstance(colors[0], str):
if isinstance(colors, tuple):
new_color_tuple = (
function(colors[0]),
function(colors[1]),
function(colors[2])
)
return new_color_tuple
for index, color in enumerate(colors):
colors[index] = function(color)
return colors
else:
return function(colors)

@staticmethod
def _unconvert_from_RGB_255(colors):
"""
Expand All @@ -2277,24 +2301,11 @@ def _unconvert_from_RGB_255(colors):
a value between 0 and 1

"""
if isinstance(colors, tuple):
un_rgb_color = (colors[0]/(255.0),
colors[1]/(255.0),
colors[2]/(255.0))

un_rgb_color = (colors[0]/(255.0),
colors[1]/(255.0),
colors[2]/(255.0))

return un_rgb_color

if isinstance(colors, list):
un_rgb_colors = []
for color in colors:
un_rgb_color = (color[0]/(255.0),
color[1]/(255.0),
color[2]/(255.0))

un_rgb_colors.append(un_rgb_color)

return un_rgb_colors
return un_rgb_color

@staticmethod
def _map_z2color(zval, colormap, vmin, vmax):
Expand Down Expand Up @@ -3082,7 +3093,6 @@ def _scatterplot_theme(dataframe, headers, diag, size, height, width,
c_indx += 1
trace_list.append(unique_index_vals)
legend_param += 1
#return trace_list

trace_index = 0
indices = range(1, dim + 1)
Expand Down Expand Up @@ -3606,22 +3616,10 @@ def _endpts_to_intervals(endpts):
@staticmethod
def _convert_to_RGB_255(colors):
"""
Return a (list of) tuple(s) where each element is multiplied by 255

Takes a tuple or a list of tuples where each element of each tuple is
between 0 and 1. Returns the same tuple(s) where each tuple element is
multiplied by 255
Multiplies each element of a triplet by 255
"""

if isinstance(colors, tuple):
return (colors[0]*255.0, colors[1]*255.0, colors[2]*255.0)

else:
colors_255 = []
for color in colors:
rgb_color = (color[0]*255.0, color[1]*255.0, color[2]*255.0)
colors_255.append(rgb_color)
return colors_255
return (colors[0]*255.0, colors[1]*255.0, colors[2]*255.0)

@staticmethod
def _n_colors(lowcolor, highcolor, n_colors):
Expand Down Expand Up @@ -3652,24 +3650,9 @@ def _n_colors(lowcolor, highcolor, n_colors):
@staticmethod
def _label_rgb(colors):
"""
Takes tuple(s) (a, b, c) and returns rgb color(s) 'rgb(a, b, c)'

Takes either a list or a single color tuple of the form (a, b, c) and
returns the same color(s) with each tuple replaced by a string
'rgb(a, b, c)'

Takes tuple (a, b, c) and returns an rgb color 'rgb(a, b, c)'
"""
if isinstance(colors, tuple):
return ('rgb(%s, %s, %s)' % (colors[0], colors[1], colors[2]))
else:
colors_label = []
for color in colors:
color_label = ('rgb(%s, %s, %s)' % (color[0],
color[1],
color[2]))
colors_label.append(color_label)

return colors_label
return ('rgb(%s, %s, %s)' % (colors[0], colors[1], colors[2]))

@staticmethod
def _unlabel_rgb(colors):
Expand All @@ -3680,52 +3663,25 @@ def _unlabel_rgb(colors):
such colors and returns the color tuples in tuple(s) (a, b, c)

"""
if isinstance(colors, str):
str_vals = ''
for index in range(len(colors)):
try:
float(colors[index])
str_vals = ''
for index in range(len(colors)):
try:
float(colors[index])
str_vals = str_vals + colors[index]
except ValueError:
if (colors[index] == ',') or (colors[index] == '.'):
Copy link
Contributor

@theengineear theengineear Jun 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐄 Please Excuse Me Dear Aunt Sally, but no need for the () in there. Check out Python's Order of Operations. or is only evaluated before lambda.

str_vals = str_vals + colors[index]
except ValueError:
if (colors[index] == ',') or (colors[index] == '.'):
str_vals = str_vals + colors[index]

str_vals = str_vals + ','
numbers = []
str_num = ''
for char in str_vals:
if char != ',':
str_num = str_num + char
else:
numbers.append(float(str_num))
str_num = ''
return (numbers[0], numbers[1], numbers[2])

if isinstance(colors, list):
unlabelled_colors = []
for color in colors:
str_vals = ''
for index in range(len(color)):
try:
float(color[index])
str_vals = str_vals + color[index]
except ValueError:
if (color[index] == ',') or (color[index] == '.'):
str_vals = str_vals + color[index]

str_vals = str_vals + ','
numbers = []
str_vals = str_vals + ','
numbers = []
str_num = ''
for char in str_vals:
if char != ',':
str_num = str_num + char
else:
numbers.append(float(str_num))
str_num = ''
for char in str_vals:
if char != ',':
str_num = str_num + char
else:
numbers.append(float(str_num))
str_num = ''
unlabelled_tuple = (numbers[0], numbers[1], numbers[2])
unlabelled_colors.append(unlabelled_tuple)

return unlabelled_colors
return (numbers[0], numbers[1], numbers[2])

@staticmethod
def create_scatterplotmatrix(df, dataframe=None, headers=None,
Expand Down

AltStyle によって変換されたページ (->オリジナル) /