verkehrsbetriebezuerich / catmaply Goto Github PK
View Code? Open in Web Editor NEW'catmaply' package for 'R'
License: Other
'catmaply' package for 'R'
License: Other
At the moment, field coloring is dependent on the category order in the data frame. See this example:
library(catmaply)
df <- vbz[[1]]$data
# ordering smallest to largest Kat
df <- df %>% arrange(-desc(Ausl_Kat))
catmaply(
df,
x = fahrt_seq,
y = halt_seq,
vals = Ausl_Kat
)
# ordering largest to smallest Kat
# inverses color order
df <- df %>% arrange(desc(Ausl_Kat))
catmaply(
df,
x = fahrt_seq,
y = halt_seq,
vals = Ausl_Kat
)
Field colors should be in ascending order based on the respective category column.
Parameter categorical_colorbar
is not entirely correct, as it can also be used with no legend at all and display categorical color_ranges per category.
Rename it to categorical_color_range
I apologise if I'm missing something, but after looking around I haven't found a way to implement the xgap and ymap traces in order to add some white space between the "bricks". Please let me know if there is any way to do this or if it could be implemented.
Thanks for your work developing this package.
If number of categories is lower than number of colors in color palette, reduce color palette
Describe the bug
Package cannot be deployed to CRAN:
Error message:
Please see the problems shown on
https://cran.r-project.org/web/checks/check_results_catmaply.html.
In particular, please see the "Found the following HTML validation
problems" NOTEs in the "HTML version of manual" check for the r-devel
debian checks results.
R 4.2.0 switched to use HTML5 for documentation pages. Now validation
using HTML Tidy finds problems in the HTML generated from your Rd files
of the form
element removed from HTML5
element removed from HTML5 attribute "align" not allowed for HTML5 attribute "hspace" not allowed for HTML5 attribute "width" has invalid value "120px" attribute "width" has invalid value "480px" attribute "width" has invalid value "50px" attribute "width" has invalid value "72px"For the first four, please see
https://html.spec.whatwg.org/#obsolete-but-conforming-features for
info on these: in principle, all can be fixed by using style attributes,
e.g.
style='text-align: right;'
instead of align='right' etc., which will work for both the new and old
ways of converting Rd to HTML.
For the second four, simply drop the px units: the HTML5 standard asks
for a non-negative integer implied to be in CSS pixels.
Can you please fix as necessary?
Note that the problems are found in Rd files auto-generated with
roxygen2: to fix it might suffice to re-generate these using the current
CRAN version of roxygen2.
Fix and resubmit to cran
Allow custom ordering of x and y axis (decreasing/ascending)
Add some examples of the usage of catmaply directly to the "front page" (Readme.md) in this repository. Idea: Get a good first impression of what catmaply does without having to install it.
currently, it is not allows to use custom color ranges per categories with the catmaply_single trace. It should be possible to:
also; when using catmaply single without displaying the legend; warnings should be thrown that
Describe the bug
When plotting with a categorical color range and no interactive legend ("legend_interactive = FALSE"), the color range is biased, some values appear as if they belong to a different category than they actually are in.
Thanks for considering the issue.
I'll be ready for eventual questions.
Cheers, Simon
To Reproduce
To reproduce you can use the available "vbz" data.
The code to reproduce is given below. Execute it onec as it is and an other time with the option "legend interactive = TRUE":
data("vbz")
df <- vbz[[3]]
catmaply(
df,
x = trip_id,
x_order = trip_seq,
y = stop_name,
y_order = stop_seq,
z = occupancy,
categorical_color_range = TRUE,
categorical_col = occ_category,
legend_interactive = FALSE,
hover_template = paste(
"Time:", departure_time,
"
Stop:", stop_name,
"
Occupancy:", occupancy,
"
Occupancy Category:", occ_cat_name,
"
No Of Measurements:", number_of_measurements,
""
),
legend_col = occ_cat_name
)
Expected behavior
I would expect the colors in the plot to stay the same for each square within the heatmap plot, since neither the values nor their categories change. It's just the legend type which changes. Instead, the colors are shifted such that for some of the squares the category seems to change, which is not true.
With the interactive legend the color category and the variable category seem to match, whereas with the non-interactive legend, they seem to be offset.
Screenshots
Screenshot of a non-interactive example, where a square (courseno.: 17020, station name: Zuerich, Kreuzplatz) with a value of the category "medium high" appears in a color which clearly is within the color palette of the category "high":
The very same example but this time with the interactive legend shows, that the same square now belongs to the correct category "medium high":
Environment:
Append result of sessionInfo()
.
sessionInfo.txt
Add capability to add annotations to catmaply
Hover generates "%{text} medium high" at empty fields. It would be better if there is no hoverinfo at empty fields.
x-axis ignores "x_order" when input column for "x" is not the same as for "x_order". Creates some unwanted overlapping. It doesn't matter if "x" is unique or not.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.