Package: hammock-plot
Hammock plotDescriptionhammock draws a graph to visualize categorical data - though it also does fine with continuous data.
Variables are lined up parallel to the vertical axis. Categories within a variable are spread out along a
vertical line. Categories of adjacent variables are connected by boxes. (The boxes are parallelograms; we
use boxes for brevity). The "width" of a box is proportional to the number of observations that correspond
to that box (i.e. have the same values/categories for the two variables). The "width" of a box refers to the
distance between the longer set of parallel lines rather than the vertical distance.

If the boxes degenerate to a single line, and no labels or missing values are used the hammock plot
corresponds to a parallel coordinate plot. Boxes degenerate into a single line if barwidth is so small that
the boxes for categorical variables appear to be a single line. For continuous variables boxes will usually
appear to be a single line because each category typically only contains one observation.

The order of variables in varlist determines the order of variables in the graph.  All variables in varlist
must be numerical. String variables should be converted to numerical variables first, e.g. using encode or
destring.Getting startedYou can install hammock frompip:pipinstallhammock_plotExample: Asthma dataWe import the diabetes dataset:importhammock_plotimportpandasaspddf=pd.read_csv('../examples/asthma/asth_all3_for_python.csv')Minimal example of a hammock plot:var=["hospitalizations","group","gender","comorbidities"]hammock=hammock_plot.Hammock(data_df=df)ax=hammock.plot(var=var)The ordering of the child-adolescent-adult variable is not in the desired order; adult should not be in the middle. We now specify a specific order, child-adolescent-adult.var=["hospitalizations","group","gender","comorbidities"]group_dict={1:"child",2:"adolescent",3:"adult"}value_order={"group":group_dict}hammock=hammock_plot.Hammock(data_df=df)ax=hammock.plot(var=var,value_order=value_order)We highlight observations with comorbidities=0  in red:ax=hammock.plot(var=var,value_order=value_order,hi_var="comorbidities",hi_value=[0],color=["red"])Example Satisfaction scales for the diabetes dataWe import the diabetes dataset:importhammock_plotimportpandasaspddf=pd.read_csv('../examples/diabetes_outlier/diabetes_for_python.csv')The three variables represent different ordinal scales for satisfaction. We are checking for missing values:var=["sataces","satcomm","satrate"]hammock=hammock_plot.Hammock(data_df=df)ax=hammock.plot(var=var,default_color="blue",missing=True)The missing value category is shown at the bottom for each variable. We find missing values for all 3 variables, but fewest for the last one. We also see a phenomenon called "top coding", where
satisfied respondents simply choose the highest value.API Referencehammock()CategoryParameterTypeDescriptionGeneralvarList[str]List of variables to display.value_orderDict[str, Dict[int, str]]If specified, the order of the values in the plot follows the order of values in the list supplied in the dictionary. A specific value order is useful, for example, for ordered variables. The integer values affect spacing: for example the values 4,5,6 imply equal spacing between 4,5 and 5,6. The values 4,5,7 implies twice as much space between 5,7 as between 4,5.missingboolWhether or not to add a category for missing values at the bottom of the plot.  If False, observations that have a missing value for any variable in the data frame (even those not used in the hammock plot) are removed.  Default is False.labelboolWhether or not to display labels between the plotting segmentsHighlightinghi_varstrVariable to be highlighted. Default is none.hi_valueList[str or int]List of values ofhi_varto be highlighted. You can highlighted one or multiple values.hi_missingboolWhether or not missing values forhi_varshould be highlighted.colorList[str]List of colors corresponding to the list of values to be highlighted. Default highlight color list is ["red", "green", "yellow", "lightblue", "orange", "gray", "brown", "olive", "pink", "cyan", "magenta"]default_colorstrDefault color of plotting elements for boxes that are not highlighted. Default is "blue"Manipulating Spacing and Layoutbar_widthfloatFactor by which the default width is  increased or reduced. This allows reducing visual clutter. Default is 1.0.spacefloatSpace left for the labels between the plotting elements. Default is 0.5label_optionsDict[str, Dict[str, Any]]Manipulates the size and look of the labels. Args following the options in the website:https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.text.htmlExample:{"ExampleVarname":{"fontsize":12,"fontstyle":"italic","fontweight":"black","color":"b"}}  Default is None.heightfloatHeight of the plot in inches. Default is 10.widthfloatWidth of the plot in inches. Default is 15. Caution: Width too narrow may distort the plot.Other optionsshapestrShape of the boxes. "rectangle" (default) or "parallelogram".same_scaleList[str]List of variables that have the same scale. Default is None.display_figureboolWhether or not to display the figure. This can be useful if you just want to save the plots. Default is 'True'.save_pathstrIf it is not None, the figure will be saved to the given path with given name and format. Default is None.Historical contextIn 1898, Sankey diagrams were developed to visualize flows of energy and materials.In 1985, Inselberg popularized parallel coordinates to visualize continuous variables only. The central contribution is the use of parallel axes.In 2003, Schonlau proposed the hammock plot. This was the first plot to visualize categorical data (or mixed categorical continuous data) on parallel axes.In 2010, Rosvall proposed alluvial plots to visualize network variables over time. Rather than using bars to connect axes, alluvial plots use rounded curves. Alluvial plots are now also used to visualize categorical data.There are several additional variations that also visualize categorical data including Parallel Set plots (Bendix et al, 2005) and Right Angle plots (Hofmann and Vendettuoli, 2013).ReferencesBendix, F., Kosara, R., & Hauser, H. (2005). Parallel sets: visual analysis of categorical data. In IEEE Symposium on Information Visualization, 2005. INFOVIS 2005. 133-140.Hofmann, H., & Vendettuoli, M. (2013). Common angle plots as perception-true visualizations of categorical associations. IEEE transactions on visualization and computer graphics, 19(12), 2297-2305.Inselberg, A., & Dimsdale, B. (2009). Parallel coordinates. Human-Machine Interactive Systems, 199-233.Rosvall, Martin, & Bergstrom, C.T. (2010) "Mapping change in large networks." PloS one 5.1: e8694.Sankey, H. (1898). Introductory note on the thermal efficiency of steam-engines. report of
the committee appointed on the 31st march, 1896, to consider and report to the council
upon the subject of the definition of a standard or standards of thermal efficiency for
steam-engines: With an introductory note. In Minutes of proceedings of the institution
of civil engineers, Volume 134, pp. 278–283.Schonlau M.Visualizing Categorical Data Arising in the Health Sciences Using Hammock Plots.In Proceedings of the Section on Statistical Graphics, American Statistical Association; 2003Other implementations of the hammock plotThere is also a Stata implementationhammock(available from the Stata archive SSC) and an R implementation as part of the packageggparallel.AuthorsTiancheng Yangt77yang@uwaterloo.ca