Showing posts with label geometry. Show all posts
Showing posts with label geometry. Show all posts

16 February 2021

📊🐍Python: Drawing Concentric Circles with matplotlib.pyplot

Today I tried using for the first time the matplotlib library for drawing a few concentric circles, though it proved to be a bit more challenging than expected, as the circles were distorted given the scale differences between x and y axis. Because of this the circles displayed via the Circle class (in blue) seem to be displayed as ellipses. To show the difference I used  trigonometric functions to draw the circles (in green) by applying a 5/7.5 multiplication factor for the x axis:

And here's the code:

import numpy as np
import math as m
import matplotlib.pyplot as plt

axis_dimensions = [-100,100, -100,100] #dimensions axis
dx=10       #distance between ticks on x axis 
dy=10       #distance between ticks on y axis
sfx = 5/7.5 #scale factor for x axis
r= 50       #radius

#drawing the grid
plt.axis(axis_dimensions)
plt.axis('on')
plt.grid(True, color='gray')
plt.xticks(np.arange(axis_dimensions[0], axis_dimensions[1], dx))
plt.yticks(np.arange(axis_dimensions[2], axis_dimensions[3], dy))

#adding labels
plt.title('Circles')
plt.xlabel('x axis')
plt.ylabel('y axis')

#drawing the geometric figures
for i in range(0,51,10):
    for angle in np.arange(m.radians(0),m.radians(360),m.radians(2)):
        #drawing circles via trigonometric functions
        x = (r+i)*m.cos(angle)*sfx
        y = (r+i)*m.sin(angle)
        plt.scatter(x,y,s=2,color ='g')
        
    #drawing with circles
    circle = plt.Circle((0,0),r+i,color='b', fill=False)
    plt.gca().add_patch(circle)

plt.show()

Happy coding!

08 November 2011

📉Graphical Representation: Curvature (Just the Quotes)

"Characterizing a two-dimensional scatterplot is relatively easy, particularly with the full range of recently developed graphical enhancements at hand. However, standard patterns to watch for in three-dimensional plots are not as well understood as they are in many two-dimensional plots. We can certainly look for very general characteristics like curvature in three-dimensional plots, but it may not be clear how or if the curvature itself should be characterized. It is also possible to obtain useful insights into higher-dimensional scatterplots, but for the most part their interpretation must rely on lower-dimensional constructions. Similar statements apply to scatterplot matrices and various linked plots." (R Dennis Cook, "Regression Graphics: Ideas for Studying Regressions through Graphics", 1998)

"The fundamental concept of Gauss’s surface theory is the curvature, a quantity that is positive (and constant) for a sphere, zero for the plane and cylinder, and negative for surfaces that are 'saddle-shaped' in the neighborhood of each point." (John Stillwell, "The Four Pillars of Geometry", 2000) 

"Even though hyperbolic trees employ the same ranking principle as radial trees, based on a series of concentric circles, they do not operate in conventional Euclidean space, but instead within a spherical negative curvature based on hyperbolic geometry. Due to their magnifying feature, hyperbolic trees are useful for displaying and manipulating large hierarchies on a limited screen size. As visualizations ideally suited for direct manipulation, hyperbolic trees are rarely depicted in print and are found almost exclusively within the confines of their natural digital domain." (Manuel Lima, "The Book of Trees: Visualizing Branches of Knowledge", 2014)

"Once a model has been fitted to the data, the deviations from the model are the residuals. If the model is appropriate, then the residuals mimic the true errors. Examination of the residuals often provides clues about departures from the modeling assumptions. Lack of fit - if there is curvature in the residuals, plotted versus the fitted values, this suggests there may be whole regions where the model overestimates the data and other whole regions where the model underestimates the data. This would suggest that the current model is too simple relative to some better model.(DeWayne R Derryberry, "Basic data analysis for time series with R", 2014)

"A visual channel is a way to control the appearance of marks, independent of the dimensionality of the geometric primitive. […]  The motion-oriented channels include the motion pattern, for in stance, oscillating circles versus straight jumps, the direction of motion, and the velocity. Angle is also a channel, sometimes called tilt. Curvature is also a visual channel. Shape is a complex phenomenon, but it is treated as a channel in this framework." (Tamara Munzner, "Visualization: Analysis & Design", 2015) 

"Tensor fields typically contain a matrix at each cell in the field, capturing more complex structure than what can be expressed in a vector field. Tensor fields can measure properties such as stress, conductivity, curvature, and diffusivity." (Tamara Munzner, "Visualization: Analysis & Design", 2015) 

"The curvature channel is not very accurate, and it can only be used with line marks. It cannot be used with point marks that have no length, or area marks because their shape is fully constrained. The number of distinguishable bins for this channel is low, probably around two or three; it is in an equivalence class with volume (3D size) at the bottom of the magnitude channel ranking." (Tamara Munzner, "Visualization: Analysis & Design", 2015)

"Important features to look for in a scatter plot are whether there is one cloud of dots or several clusters, whether there is an upward or downward slope to the cloud of dots, and whether there is any curvature to the slope." (Robert Grant, "Data Visualization: Charts, Maps and Interactive Graphics", 2019)

"Adjusting scale is an important practice in data visualization. While the log transform is versatile, it doesn’t handle all situations where skew or curvature occurs. For example, at times the values are all roughly the same order of magnitude and the log transformation has little impact. Another transformation to consider is the square root transformation, which is often useful for count data." (Sam Lau et al, "Learning Data Science: Data Wrangling, Exploration, Visualization, and Modeling with Python", 2023)

03 November 2011

📉Graphical Representation: Circles (Just the Quotes)

"Comparison between circles of different size should be absolutely avoided. It is inexcusable when we have available simple methods of charting so good and so convenient from every point of view as the horizontal bar." (Willard C Brinton, "Graphic Methods for Presenting Facts", 1919)

"In general, the comparison of two circles of different size should be strictly avoided. Many excellent works on statistics approve the comparison of circles of different size, and state that the circles should always be drawn to represent the facts on an area basis rather than on a diameter basis. The rule, however, is not always followed and the reader has no way of telling whether the circles compared have been drawn on a diameter basis or on an area basis, unless the actual figures for the data are given so that the dimensions may be verified." (Willard C Brinton, "Graphic Methods for Presenting Facts", 1919)

"Although the pie or sector chart ranks very high in popular appeal, it is held in rather low esteem by many specialists in graphic presentation. Since the pie chart possesses more weaknesses perhaps than most graphic forms, it is especially important to observe proper discretion in its construction and application. The pie chart is used to portray component relations. The various sectors of a circle represent component parts of an aggregate or total." (Calvin F Schmid, "Handbook of Graphic Presentation", 1954)

"First, it is generally inadvisable to attempt to portray a series of more than four or five categories by means of pie charts. If, for example, there are six, eight, or more categories, it may be very confusing to differentiate the relative values portrayed, especially if several small sectors are of approximately the same size. Second, the pie chart may lose its effectiveness if an attempt is made to compare the component values of several circles, as might be found in a temporal or geographical series. In such case the one-hundred percent bar or column chart is more appropriate. Third, although the proportionate values portrayed in a pie chart are measured as distances along arcs about the circle, actually there is a tendency to estimate values in terms of areas of sectors or by the size of subtended angles at the center of the circle." (Calvin F Schmid, "Handbook of Graphic Presentation", 1954)

"Circles of different size, however cannot properly be used to compare the size of different totals. This is because the reader does not know whether to compare the diameters or the areas" (which vary as the squares of the diameters), and is likely to misjudge the comparison in either ease. Usually the circles are drawn so that their diameters are in correct proportion to each other; but then the area comparison is exaggerated. Component bars should be used to show totals of different size since their one dimension lengths can be easily judged not only for the totals themselves but for the component parts as well. Circles, therefore, can show proportions properly by variations in angles of sectors but not by variations in diameters. " (Anna C Rogers, "Graphic Charts Handbook", 1961)

"Pie charts have weaknesses and dangers inherent in their design and application. First, it is generally inadvisable to attempt to portray more than four or five categories in a circle chart, especially if several small sectors are of approximately the same size.  It may be very confusing to differentiate the relative values. Secondly, the pie chart loses effectiveness if an effort is made to compare the component values of several circles, as might occur in a temporal or geographical series. [...] Thirdly, although values are measured by distances along the arc of the circle, there is a tendency to estimate values in terms of areas by size of angle. The 100-percent bar chart is often preferable to the circle chart's angle and area comparison as it is easier to divide into parts, more convenient to use, has sections that may be shaded for contrast with grouping possible by bracketing, and has an easily readable percentage scale outside the bars." (Anna C Rogers, "Graphic Charts Handbook", 1961)

"Data should not be forced into an uncomfortable or improper mold. For example, data that is appropriate for line graphs is not usually appropriate for circle charts and in any case not without some arithmetic transformation. Only graphs that are designed to fit the data can be used profitably." (Cecil H Meyers, "Handbook of Basic Graphs: A modern approach", 1970)

"In certain respects, line graphs are uniquely applicable to particular graphic requirements for which a bar or circle chart could not be substituted. Strictly speaking, the line graph must be used to portray changes in a continuous variable, since technically such a variable must be represented by a line and not by 'points' or 'bars'. Line graphs are often uniquely applicable to problems of analysis, particularly when it is essential to visualize a trend, observe the behavior of a set of variables through time, or portray the same variable in differing time periods." (Cecil H Meyers, "Handbook of Basic Graphs: A modern approach", 1970)

"The varieties of circle charts are necessarily limited by the lack of basic design variation - a circle is a circle! Also, a circle can be considered as representing only one unit of area. regardless of its size. Thus, circle charts have limited applications, i.e., to show how a given quantity" (area) is divided among its component parts,' or to show changes in the variable by showing area changes. A circle chart almost always presents some form of a part-to-total relationship." (Cecil H Meyers, "Handbook of Basic Graphs: A modern approach", 1970)

"While circle charts are not likely to present especially new or creative ideas, they do help the user to visualize relationships. The relationships depicted by circle charts do not tend to be very complex, in contrast to those of some line graphs. Normally, the circle chart is used to portray a common type of relationship" (namely. part-to-total) in an attractive manner and to expedite the message transfer from designer to user." (Cecil H Meyers, "Handbook of Basic Graphs: A modern approach", 1970)

A pie graph is a circle that is divided into wedges, like slices of a pie. It is particularly useful when statistics show as a half or a quarter of a total. The human eye can recognize half of a circle much more easily than half a length of a bar." (Dyno Lowenstein, "Graphs", 1976)

The circle graph, or pie chart, appears to simple and 'nonstatistical', so it is a popular form of presentation for general readers. However, since the eye can compare linear distances more easily and accurately than angles or areas, the component parts of a total usually can be shown more effectively in a chart using linear measurement." (Peter H Selby, "Interpreting Graphs and Tables", 1976)

A pie chart is comprised of a circle that is divided into segments by straight lines within the circle. The circle represents the total or whole amount. Each segment or wedge of the circle represents the proportion that a particular factor is of the total or whole amount. Thus, a pie chart in its entirety always represents whole amounts of either 100% or a total absolute number, such as 100 cents or 5,000 people. All of the segments of the pie when taken together" (that is, in the aggregate) must add up to the total." (Robert Lefferts, "Elements of Graphics: How to prepare charts and graphs for effective reports", 1981)

"Visual thinking can begin with the three basic shapes we all learned to draw before kindergarten: the triangle, the circle, and the square. The triangle encourages you to rank parts of a problem by priority. When drawn into a triangle, these parts are less likely to get out of order and take on more importance than they should. While the triangle ranks, the circle encloses and can be used to include and/or exclude. Some problems have to be enclosed to be managed. Finally, the square serves as a versatile problem-solving tool. By assigning it attributes along its sides or corners, we can suddenly give a vague issue a specific place to live and to move about." (Terry Richey, "The Marketer's Visual Tool Kit", 1994)

"Two types of graphic organizers are commonly used for comparison: the Venn diagram and the comparison matrix [...] the Venn diagram provides students with a visual display of the similarities and differences between two items. The similarities between elements are listed in the intersection between the two circles. The differences are listed in the parts of each circle that do not intersect. Ideally, a new Venn diagram should be completed for each characteristic so that students can easily see how similar and different the elements are for each characteristic used in the comparison." (Robert J. Marzano et al, "Classroom Instruction that Works: Research-based strategies for increasing student achievement, 2001)

"Radar charts are almost always the result either of space-saving attempts or of doubtful theories about the desirability of 'symmetrical' plots, in which scores on all dimensions are similar, so giving an approximation to a circle. Their scales offer unlimited scope for manipulation in achieving this lunatic ambition." (Nicholas Strange, "Smoke and Mirrors: How to bend facts and figures to your advantage", 2007)

"Diagrams are information graphics that are made up primarily of geometric shapes, such as rectangles, circles, diamonds, or triangles, that are typically" (but not always) interconnected by lines or arrows. One of the major purposes of a diagram is to show how things, people, ideas, activities, etc. interrelate and interconnect. Unlike quantitative charts and graphs, diagrams are used to show interrelationships in a qualitative way." (Robbie T Nakatsu, "Diagrammatic Reasoning in AI", 2010)

"Area can also make data seem more tangible or relatable, because physical objects take up space. A circle or a square uses more space than a dot on a screen or paper. There’s less abstraction between visual cue and real world." (Nathan Yau, "Data Points: Visualization That Means Something", 2013)

"Circles are among the most ubiquitous symbols around the globe, used in countless variations since the birth of humankind. Associated with notions of unity, wholeness, and infinity, the circle has been an important visual metaphor in a wide array of systems of thought, from cartography and astronomy to physics and geometry. " (Manuel Lima, "The Book of Trees: Visualizing Branches of Knowledge", 2014)

"Standard graphs, like bar and line charts, are so common because they are perceptually more accurate, familiar to people, and easy to create. Nonstandard graphs - those that use circles or curves, for instance - may not allow the reader to most accurately perceive the exact data values. But perceptual accuracy is not always the goal. And sometimes it's not a goal at all. Spurring readers to engage with a graph is sometimes just as important. Sometimes, it's more important. And nonstandard chart types may do just that. In some cases, nonstandard graphs may help show underlying patterns and trends in better ways that standard graphs. In other cases, the fact that these nonstandard graphs are different may make them more engaging, which we may sometimes need to first attract attention to the visualization."  (Jonathan Schwabish, "Better Data Visualizations: A guide for scholars, researchers, and wonks", 2021)

"The radial bar chart, also called the polar bar chart, arranges the bars to radiate outward from the center of a circle. This graph lies lowers on the perceptual ranking list because it is harder to compare the heights of the bars arranged around a circle than when they are arranged along a single flat axis. But this layout does allow you to fit more values in a compact space, and makes the radial bar chart well-suited for showing more data, frequent changes (such as monthly or daily), or changes over a long period of time." (Jonathan Schwabish, "Better Data Visualizations: A guide for scholars, researchers, and wonks", 2021)

02 November 2011

📉Graphical Representation: Rectangles (Just the Quotes)

"The bar or column chart is the easiest type of graphic to prepare and use in reports. It employs a simple form: four straight lines that are joined to construct a rectangle or oblong box. When the box is shown horizontally it is called a bar; when it is shown vertically it is called a column. [...] The bar chart is an effective way to show comparisons between or among two or more items. It has the added advantage of being easily understood by readers who have little or no background in statistics and who are not accustomed to reading complex tables or charts." (Robert Lefferts, "Elements of Graphics: How to prepare charts and graphs for effective reports", 1981)

"Unlike some art forms. good graphics should be as concrete, geometrical, and representational as possible. A rectangle should be drawn as a rectangle, leaving nothing to the reader's imagination about what you are trying to portray. The various lines and shapes used in a graphic chart should be arranged so that it appears to be balanced. This balance is a result of the placement of shapes and lines in an orderly fashion." (Robert Lefferts, "Elements of Graphics: How to prepare charts and graphs for effective reports", 1981)

"The practice of framing an illustration with a drawn rectangle is not recommended. This kind of typographic detailing should never be added purely for aesthetic reasons or for decoration. A simple, purely functional drawing will automatically be aesthetically pleasing. Unnecessary lines usually reduce both legibility and attractiveness." (Linda Reynolds & Doig Simmonds, "Presentation of Data in Science" 4th Ed, 1984)

"The square has always had a no-nonsense sort of image. Stable, solid, and - well - square. Perhaps that's why it is the shape used in business visuals in those rare cases where a visual is even bothered with. Flip through most business books and you'll find precious few places for your eye to stop and your visual brain to engage. But when you do, the shape of the graphic, chart, matrix, table, or diagram is certainly square. It's a comfortable shape, which makes it a valuable implement in your kit of visual communication tools." (Terry Richey, "The Marketer's Visual Tool Kit", 1994)

"Visual thinking can begin with the three basic shapes we all learned to draw before kindergarten: the triangle, the circle, and the square. The triangle encourages you to rank parts of a problem by priority. When drawn into a triangle, these parts are less likely to get out of order and take on more importance than they should. While the triangle ranks, the circle encloses and can be used to include and/or exclude. Some problems have to be enclosed to be managed. Finally, the square serves as a versatile problem-solving tool. By assigning it attributes along its sides or corners, we can suddenly give a vague issue a specific place to live and to move about." (Terry Richey, "The Marketer's Visual Tool Kit", 1994)

"A Venn diagram is a simple representation of the sample space, that is often helpful in seeing 'what is going on'. Usually the sample space is represented by a rectangle, with individual regions within the rectangle representing events. It is often helpful to imagine that the actual areas of the various regions in a Venn diagram are in proportion to the corresponding probabilities. However, there is no need to spend a long time drawing these diagrams - their use is simply as a reminder of what is happening." (Graham Upton & Ian Cook, "Introducing Statistics", 2001)

"Diagrams are information graphics that are made up primarily of geometric shapes, such as rectangles, circles, diamonds, or triangles, that are typically" (but not always) interconnected by lines or arrows. One of the major purposes of a diagram is to show how things, people, ideas, activities, etc. interrelate and interconnect. Unlike quantitative charts and graphs, diagrams are used to show interrelationships in a qualitative way." (Robbie T Nakatsu, "Diagrammatic Reasoning in AI", 2010)

"A histogram for discrete numerical data is a graph of the frequency or relative frequency distribution, and it is similar to the bar chart for categorical data. Each frequency or relative frequency is represented by a rectangle centered over the corresponding value" (or range of values) and the area of the rectangle is proportional to the corresponding frequency or relative frequency." (Roxy Peck et al, "Introduction to Statistics and Data Analysis" 4th Ed., 2012)

"The use of the density scale to construct the histogram ensures that the area of each rectangle in the histogram will be proportional to the corresponding relative frequency. The formula for density can also be used when class widths are equal. However, when the intervals are of equal width, the extra arithmetic required to obtain the densities is unnecessary." (Roxy Peck et al, "Introduction to Statistics and Data Analysis" 4th Ed., 2012)

"Area can also make data seem more tangible or relatable, because physical objects take up space. A circle or a square uses more space than a dot on a screen or paper. There’s less abstraction between visual cue and real world." (Nathan Yau, "Data Points: Visualization That Means Something", 2013)

Related Posts Plugin for WordPress, Blogger...

About Me

My photo
Koeln, NRW, Germany
IT Professional with more than 25 years experience in IT in the area of full life-cycle of Web/Desktop/Database Applications Development, Software Engineering, Consultancy, Data Management, Data Quality, Data Migrations, Reporting, ERP implementations & support, Team/Project/IT Management, etc.