83799

Gnuplot: Bar chart from a function

In difference to nearly 99.9% of all Gnuplot bar chart examples I don't have a data file but a function I want to visualize as a bar chart.

Let us take for example take the simple function f(x) = x

I want a bar char that creates one bar for every value of x between 0 and 20 (step size 1).

Therefore I used the following code, but it does not create 20 bars - it creates a lot more (about 100?).

set xtic 1 set xrange [0:20] set boxwidth 1 set style fill solid f(x)=x plot f(x) with boxes

How to make this bar chart work correctly?

Answer1:

You want the set samples command. Try:

set xtic 1 set xrange [0:20] set boxwidth 1 set style fill solid f(x)=x set samples 21 plot f(x) with boxes

Recommend

  • Scaling of multiplot while using variables to define the column
  • Lua Error: “Gnuplot terminal is not set”
  • Visualizing a balanced tree
  • Project point from point cloud to Image in OpenCV
  • GNUPLOT: Show a x value given a y value
  • Portable package installation on Haskell Platform with Cabal on windows
  • Dynamic Programming Problem.. Array Partitioning..
  • Using C++ templating for SFML Resource Manager
  • Crystal Report : “File is too large for attachment” Error
  • How to query with a where clause in mysql json table
  • Retrieving data points from scipy interpolate/griddata
  • Slowly changing dimension - What is Pure type 6 implementation
  • What Makes These Two Array Adds Different?
  • Bigquery event streaming and table creation
  • Debugging VB6 Code From Visual Studio 2010
  • Cannot upload to OneDrive using the new SDK
  • Diff between two dataframes in pandas
  • Unable to install Git-core+svn by MacPorts
  • Django simple Captcha “No module named fields” error
  • MailKit: The IMAP server replied to the 'EXAMINE' command with a 'BAD' response
  • Could not find rake using whenever rails
  • Change multiple background-images with jQuery
  • Change Inet root folder for iis 7
  • Android screen density dpi vs ppi
  • AES padding and writing the ciphertext to a disk file
  • How to add a column to a Pandas dataframe made of arrays of the n-preceding values of another column
  • DirectX11 ClearRenderTargetViewback with transparent buffer?
  • Change an a tag attribute in JavaScript based on screen width
  • Convert array of 8 bytes to signed long in C++
  • Comma separated Values
  • Linker errors when using intrinsic function via function pointer
  • Error creating VM instance in Google Compute Engine
  • Acquiring multiple attributes from .xml file in c#
  • Hits per day in Google Big Query
  • how does django model after text[] in postgresql [duplicate]
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • LevelDB C iterator
  • How can I remove ASP.NET Designer.cs files?
  • java string with new operator and a literal